Doxygen Source Code Documentation
netcdf.h File Reference
#include <stddef.h>#include <errno.h>Go to the source code of this file.
| Defines | |
| #define | NC_FILL_BYTE ((signed char)-127) | 
| #define | NC_FILL_CHAR ((char)0) | 
| #define | NC_FILL_SHORT ((short)-32767) | 
| #define | NC_FILL_INT (-2147483647L) | 
| #define | NC_FILL_FLOAT (9.9692099683868690e+36f) | 
| #define | NC_FILL_DOUBLE (9.9692099683868690e+36) | 
| #define | _FillValue "_FillValue" | 
| #define | NC_NOWRITE 0 | 
| #define | NC_WRITE 0x1 | 
| #define | NC_CLOBBER 0 | 
| #define | NC_NOCLOBBER 0x4 | 
| #define | NC_FILL 0 | 
| #define | NC_NOFILL 0x100 | 
| #define | NC_LOCK 0x0400 | 
| #define | NC_SHARE 0x0800 | 
| #define | NC_SIZEHINT_DEFAULT 0 | 
| #define | NC_ALIGN_CHUNK ((size_t)(-1)) | 
| #define | NC_UNLIMITED 0L | 
| #define | NC_GLOBAL -1 | 
| #define | NC_MAX_DIMS 100 | 
| #define | NC_MAX_ATTRS 2000 | 
| #define | NC_MAX_VARS 2000 | 
| #define | NC_MAX_NAME 128 | 
| #define | NC_MAX_VAR_DIMS NC_MAX_DIMS | 
| #define | NC_ISSYSERR(err) ((err) > 0) | 
| #define | NC_NOERR 0 | 
| #define | NC_EBADID (-33) | 
| #define | NC_ENFILE (-34) | 
| #define | NC_EEXIST (-35) | 
| #define | NC_EINVAL (-36) | 
| #define | NC_EPERM (-37) | 
| #define | NC_ENOTINDEFINE (-38) | 
| #define | NC_EINDEFINE (-39) | 
| #define | NC_EINVALCOORDS (-40) | 
| #define | NC_EMAXDIMS (-41) | 
| #define | NC_ENAMEINUSE (-42) | 
| #define | NC_ENOTATT (-43) | 
| #define | NC_EMAXATTS (-44) | 
| #define | NC_EBADTYPE (-45) | 
| #define | NC_EBADDIM (-46) | 
| #define | NC_EUNLIMPOS (-47) | 
| #define | NC_EMAXVARS (-48) | 
| #define | NC_ENOTVAR (-49) | 
| #define | NC_EGLOBAL (-50) | 
| #define | NC_ENOTNC (-51) | 
| #define | NC_ESTS (-52) | 
| #define | NC_EMAXNAME (-53) | 
| #define | NC_EUNLIMIT (-54) | 
| #define | NC_ENORECVARS (-55) | 
| #define | NC_ECHAR (-56) | 
| #define | NC_EEDGE (-57) | 
| #define | NC_ESTRIDE (-58) | 
| #define | NC_EBADNAME (-59) | 
| #define | NC_ERANGE (-60) | 
| #define | NC_ENOMEM (-61) | 
| #define | MSC_EXTRA | 
| #define | EXTERNL extern MSC_EXTRA | 
| #define | ncvarcpy(ncid_in, varid, ncid_out) ncvarcopy((ncid_in), (varid), (ncid_out)) | 
| #define | FILL_BYTE NC_FILL_BYTE | 
| #define | FILL_CHAR NC_FILL_CHAR | 
| #define | FILL_SHORT NC_FILL_SHORT | 
| #define | FILL_LONG NC_FILL_INT | 
| #define | FILL_FLOAT NC_FILL_FLOAT | 
| #define | FILL_DOUBLE NC_FILL_DOUBLE | 
| #define | MAX_NC_DIMS NC_MAX_DIMS | 
| #define | MAX_NC_ATTRS NC_MAX_ATTRS | 
| #define | MAX_NC_VARS NC_MAX_VARS | 
| #define | MAX_NC_NAME NC_MAX_NAME | 
| #define | MAX_VAR_DIMS NC_MAX_VAR_DIMS | 
| #define | NC_LONG NC_INT | 
| #define | NC_ENTOOL NC_EMAXNAME | 
| #define | NC_EXDR (-32) | 
| #define | NC_SYSERR (-31) | 
| #define | MAX_NC_OPEN 32 | 
| #define | NC_FATAL 1 | 
| #define | NC_VERBOSE 2 | 
| Typedefs | |
| typedef int | nclong | 
| Enumerations | |
| enum | nc_type { NC_NAT = 0, NC_BYTE = 1, NC_CHAR = 2, NC_SHORT = 3, NC_INT = 4, NC_FLOAT = 5, NC_DOUBLE = 6 } | 
| Functions | |
| EXTERNL const char * | nc_inq_libvers (void) | 
| EXTERNL const char * | nc_strerror (int ncerr) | 
| EXTERNL int | nc__create (const char *path, int cmode, size_t initialsz, size_t *chunksizehintp, int *ncidp) | 
| EXTERNL int | nc_create (const char *path, int cmode, int *ncidp) | 
| EXTERNL int | nc__open (const char *path, int mode, size_t *chunksizehintp, int *ncidp) | 
| EXTERNL int | nc_open (const char *path, int mode, int *ncidp) | 
| EXTERNL int | nc_set_fill (int ncid, int fillmode, int *old_modep) | 
| EXTERNL int | nc_redef (int ncid) | 
| EXTERNL int | nc__enddef (int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align) | 
| EXTERNL int | nc_enddef (int ncid) | 
| EXTERNL int | nc_sync (int ncid) | 
| EXTERNL int | nc_abort (int ncid) | 
| EXTERNL int | nc_close (int ncid) | 
| EXTERNL int | nc_inq (int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp) | 
| EXTERNL int | nc_inq_ndims (int ncid, int *ndimsp) | 
| EXTERNL int | nc_inq_nvars (int ncid, int *nvarsp) | 
| EXTERNL int | nc_inq_natts (int ncid, int *nattsp) | 
| EXTERNL int | nc_inq_unlimdim (int ncid, int *unlimdimidp) | 
| EXTERNL int | nc_def_dim (int ncid, const char *name, size_t len, int *idp) | 
| EXTERNL int | nc_inq_dimid (int ncid, const char *name, int *idp) | 
| EXTERNL int | nc_inq_dim (int ncid, int dimid, char *name, size_t *lenp) | 
| EXTERNL int | nc_inq_dimname (int ncid, int dimid, char *name) | 
| EXTERNL int | nc_inq_dimlen (int ncid, int dimid, size_t *lenp) | 
| EXTERNL int | nc_rename_dim (int ncid, int dimid, const char *name) | 
| EXTERNL int | nc_inq_att (int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp) | 
| EXTERNL int | nc_inq_attid (int ncid, int varid, const char *name, int *idp) | 
| EXTERNL int | nc_inq_atttype (int ncid, int varid, const char *name, nc_type *xtypep) | 
| EXTERNL int | nc_inq_attlen (int ncid, int varid, const char *name, size_t *lenp) | 
| EXTERNL int | nc_inq_attname (int ncid, int varid, int attnum, char *name) | 
| EXTERNL int | nc_copy_att (int ncid_in, int varid_in, const char *name, int ncid_out, int varid_out) | 
| EXTERNL int | nc_rename_att (int ncid, int varid, const char *name, const char *newname) | 
| EXTERNL int | nc_del_att (int ncid, int varid, const char *name) | 
| EXTERNL int | nc_put_att_text (int ncid, int varid, const char *name, size_t len, const char *op) | 
| EXTERNL int | nc_get_att_text (int ncid, int varid, const char *name, char *ip) | 
| EXTERNL int | nc_put_att_uchar (int ncid, int varid, const char *name, nc_type xtype, size_t len, const unsigned char *op) | 
| EXTERNL int | nc_get_att_uchar (int ncid, int varid, const char *name, unsigned char *ip) | 
| EXTERNL int | nc_put_att_schar (int ncid, int varid, const char *name, nc_type xtype, size_t len, const signed char *op) | 
| EXTERNL int | nc_get_att_schar (int ncid, int varid, const char *name, signed char *ip) | 
| EXTERNL int | nc_put_att_short (int ncid, int varid, const char *name, nc_type xtype, size_t len, const short *op) | 
| EXTERNL int | nc_get_att_short (int ncid, int varid, const char *name, short *ip) | 
| EXTERNL int | nc_put_att_int (int ncid, int varid, const char *name, nc_type xtype, size_t len, const int *op) | 
| EXTERNL int | nc_get_att_int (int ncid, int varid, const char *name, int *ip) | 
| EXTERNL int | nc_put_att_long (int ncid, int varid, const char *name, nc_type xtype, size_t len, const long *op) | 
| EXTERNL int | nc_get_att_long (int ncid, int varid, const char *name, long *ip) | 
| EXTERNL int | nc_put_att_float (int ncid, int varid, const char *name, nc_type xtype, size_t len, const float *op) | 
| EXTERNL int | nc_get_att_float (int ncid, int varid, const char *name, float *ip) | 
| EXTERNL int | nc_put_att_double (int ncid, int varid, const char *name, nc_type xtype, size_t len, const double *op) | 
| EXTERNL int | nc_get_att_double (int ncid, int varid, const char *name, double *ip) | 
| EXTERNL int | nc_def_var (int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp) | 
| EXTERNL int | nc_inq_var (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp) | 
| EXTERNL int | nc_inq_varid (int ncid, const char *name, int *varidp) | 
| EXTERNL int | nc_inq_varname (int ncid, int varid, char *name) | 
| EXTERNL int | nc_inq_vartype (int ncid, int varid, nc_type *xtypep) | 
| EXTERNL int | nc_inq_varndims (int ncid, int varid, int *ndimsp) | 
| EXTERNL int | nc_inq_vardimid (int ncid, int varid, int *dimidsp) | 
| EXTERNL int | nc_inq_varnatts (int ncid, int varid, int *nattsp) | 
| EXTERNL int | nc_rename_var (int ncid, int varid, const char *name) | 
| EXTERNL int | nc_copy_var (int ncid_in, int varid, int ncid_out) | 
| EXTERNL int | nc_put_var1_text (int ncid, int varid, const size_t *indexp, const char *op) | 
| EXTERNL int | nc_get_var1_text (int ncid, int varid, const size_t *indexp, char *ip) | 
| EXTERNL int | nc_put_var1_uchar (int ncid, int varid, const size_t *indexp, const unsigned char *op) | 
| EXTERNL int | nc_get_var1_uchar (int ncid, int varid, const size_t *indexp, unsigned char *ip) | 
| EXTERNL int | nc_put_var1_schar (int ncid, int varid, const size_t *indexp, const signed char *op) | 
| EXTERNL int | nc_get_var1_schar (int ncid, int varid, const size_t *indexp, signed char *ip) | 
| EXTERNL int | nc_put_var1_short (int ncid, int varid, const size_t *indexp, const short *op) | 
| EXTERNL int | nc_get_var1_short (int ncid, int varid, const size_t *indexp, short *ip) | 
| EXTERNL int | nc_put_var1_int (int ncid, int varid, const size_t *indexp, const int *op) | 
| EXTERNL int | nc_get_var1_int (int ncid, int varid, const size_t *indexp, int *ip) | 
| EXTERNL int | nc_put_var1_long (int ncid, int varid, const size_t *indexp, const long *op) | 
| EXTERNL int | nc_get_var1_long (int ncid, int varid, const size_t *indexp, long *ip) | 
| EXTERNL int | nc_put_var1_float (int ncid, int varid, const size_t *indexp, const float *op) | 
| EXTERNL int | nc_get_var1_float (int ncid, int varid, const size_t *indexp, float *ip) | 
| EXTERNL int | nc_put_var1_double (int ncid, int varid, const size_t *indexp, const double *op) | 
| EXTERNL int | nc_get_var1_double (int ncid, int varid, const size_t *indexp, double *ip) | 
| EXTERNL int | nc_put_vara_text (int ncid, int varid, const size_t *startp, const size_t *countp, const char *op) | 
| EXTERNL int | nc_get_vara_text (int ncid, int varid, const size_t *startp, const size_t *countp, char *ip) | 
| EXTERNL int | nc_put_vara_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, const unsigned char *op) | 
| EXTERNL int | nc_get_vara_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, unsigned char *ip) | 
| EXTERNL int | nc_put_vara_schar (int ncid, int varid, const size_t *startp, const size_t *countp, const signed char *op) | 
| EXTERNL int | nc_get_vara_schar (int ncid, int varid, const size_t *startp, const size_t *countp, signed char *ip) | 
| EXTERNL int | nc_put_vara_short (int ncid, int varid, const size_t *startp, const size_t *countp, const short *op) | 
| EXTERNL int | nc_get_vara_short (int ncid, int varid, const size_t *startp, const size_t *countp, short *ip) | 
| EXTERNL int | nc_put_vara_int (int ncid, int varid, const size_t *startp, const size_t *countp, const int *op) | 
| EXTERNL int | nc_get_vara_int (int ncid, int varid, const size_t *startp, const size_t *countp, int *ip) | 
| EXTERNL int | nc_put_vara_long (int ncid, int varid, const size_t *startp, const size_t *countp, const long *op) | 
| EXTERNL int | nc_get_vara_long (int ncid, int varid, const size_t *startp, const size_t *countp, long *ip) | 
| EXTERNL int | nc_put_vara_float (int ncid, int varid, const size_t *startp, const size_t *countp, const float *op) | 
| EXTERNL int | nc_get_vara_float (int ncid, int varid, const size_t *startp, const size_t *countp, float *ip) | 
| EXTERNL int | nc_put_vara_double (int ncid, int varid, const size_t *startp, const size_t *countp, const double *op) | 
| EXTERNL int | nc_get_vara_double (int ncid, int varid, const size_t *startp, const size_t *countp, double *ip) | 
| EXTERNL int | nc_put_vars_text (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const char *op) | 
| EXTERNL int | nc_get_vars_text (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, char *ip) | 
| EXTERNL int | nc_put_vars_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const unsigned char *op) | 
| EXTERNL int | nc_get_vars_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, unsigned char *ip) | 
| EXTERNL int | nc_put_vars_schar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const signed char *op) | 
| EXTERNL int | nc_get_vars_schar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, signed char *ip) | 
| EXTERNL int | nc_put_vars_short (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const short *op) | 
| EXTERNL int | nc_get_vars_short (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, short *ip) | 
| EXTERNL int | nc_put_vars_int (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const int *op) | 
| EXTERNL int | nc_get_vars_int (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, int *ip) | 
| EXTERNL int | nc_put_vars_long (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const long *op) | 
| EXTERNL int | nc_get_vars_long (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, long *ip) | 
| EXTERNL int | nc_put_vars_float (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const float *op) | 
| EXTERNL int | nc_get_vars_float (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, float *ip) | 
| EXTERNL int | nc_put_vars_double (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const double *op) | 
| EXTERNL int | nc_get_vars_double (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, double *ip) | 
| EXTERNL int | nc_put_varm_text (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const char *op) | 
| EXTERNL int | nc_get_varm_text (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, char *ip) | 
| EXTERNL int | nc_put_varm_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const unsigned char *op) | 
| EXTERNL int | nc_get_varm_uchar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, unsigned char *ip) | 
| EXTERNL int | nc_put_varm_schar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const signed char *op) | 
| EXTERNL int | nc_get_varm_schar (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, signed char *ip) | 
| EXTERNL int | nc_put_varm_short (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const short *op) | 
| EXTERNL int | nc_get_varm_short (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, short *ip) | 
| EXTERNL int | nc_put_varm_int (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const int *op) | 
| EXTERNL int | nc_get_varm_int (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, int *ip) | 
| EXTERNL int | nc_put_varm_long (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const long *op) | 
| EXTERNL int | nc_get_varm_long (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, long *ip) | 
| EXTERNL int | nc_put_varm_float (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const float *op) | 
| EXTERNL int | nc_get_varm_float (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, float *ip) | 
| EXTERNL int | nc_put_varm_double (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imapp, const double *op) | 
| EXTERNL int | nc_get_varm_double (int ncid, int varid, const size_t *startp, const size_t *countp, const ptrdiff_t *stridep, const ptrdiff_t *imap, double *ip) | 
| EXTERNL int | nc_put_var_text (int ncid, int varid, const char *op) | 
| EXTERNL int | nc_get_var_text (int ncid, int varid, char *ip) | 
| EXTERNL int | nc_put_var_uchar (int ncid, int varid, const unsigned char *op) | 
| EXTERNL int | nc_get_var_uchar (int ncid, int varid, unsigned char *ip) | 
| EXTERNL int | nc_put_var_schar (int ncid, int varid, const signed char *op) | 
| EXTERNL int | nc_get_var_schar (int ncid, int varid, signed char *ip) | 
| EXTERNL int | nc_put_var_short (int ncid, int varid, const short *op) | 
| EXTERNL int | nc_get_var_short (int ncid, int varid, short *ip) | 
| EXTERNL int | nc_put_var_int (int ncid, int varid, const int *op) | 
| EXTERNL int | nc_get_var_int (int ncid, int varid, int *ip) | 
| EXTERNL int | nc_put_var_long (int ncid, int varid, const long *op) | 
| EXTERNL int | nc_get_var_long (int ncid, int varid, long *ip) | 
| EXTERNL int | nc_put_var_float (int ncid, int varid, const float *op) | 
| EXTERNL int | nc_get_var_float (int ncid, int varid, float *ip) | 
| EXTERNL int | nc_put_var_double (int ncid, int varid, const double *op) | 
| EXTERNL int | nc_get_var_double (int ncid, int varid, double *ip) | 
| EXTERNL int | nc__create_mp (const char *path, int cmode, size_t initialsz, int basepe, size_t *chunksizehintp, int *ncidp) | 
| EXTERNL int | nc__open_mp (const char *path, int mode, int basepe, size_t *chunksizehintp, int *ncidp) | 
| EXTERNL int | nc_delete_mp (const char *path, int basepe) | 
| EXTERNL int | nc_set_base_pe (int ncid, int pe) | 
| EXTERNL int | nc_inq_base_pe (int ncid, int *pe) | 
| EXTERNL void | nc_advise (const char *cdf_routine_name, int err, const char *fmt,...) | 
| EXTERNL int | nctypelen (nc_type datatype) | 
| EXTERNL int | nccreate (const char *path, int cmode) | 
| EXTERNL int | ncopen (const char *path, int mode) | 
| EXTERNL int | ncsetfill (int ncid, int fillmode) | 
| EXTERNL int | ncredef (int ncid) | 
| EXTERNL int | ncendef (int ncid) | 
| EXTERNL int | ncsync (int ncid) | 
| EXTERNL int | ncabort (int ncid) | 
| EXTERNL int | ncclose (int ncid) | 
| EXTERNL int | ncinquire (int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimp) | 
| EXTERNL int | ncdimdef (int ncid, const char *name, long len) | 
| EXTERNL int | ncdimid (int ncid, const char *name) | 
| EXTERNL int | ncdiminq (int ncid, int dimid, char *name, long *lenp) | 
| EXTERNL int | ncdimrename (int ncid, int dimid, const char *name) | 
| EXTERNL int | ncattput (int ncid, int varid, const char *name, nc_type xtype, int len, const void *op) | 
| EXTERNL int | ncattinq (int ncid, int varid, const char *name, nc_type *xtypep, int *lenp) | 
| EXTERNL int | ncattget (int ncid, int varid, const char *name, void *ip) | 
| EXTERNL int | ncattcopy (int ncid_in, int varid_in, const char *name, int ncid_out, int varid_out) | 
| EXTERNL int | ncattname (int ncid, int varid, int attnum, char *name) | 
| EXTERNL int | ncattrename (int ncid, int varid, const char *name, const char *newname) | 
| EXTERNL int | ncattdel (int ncid, int varid, const char *name) | 
| EXTERNL int | ncvardef (int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp) | 
| EXTERNL int | ncvarid (int ncid, const char *name) | 
| EXTERNL int | ncvarinq (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp) | 
| EXTERNL int | ncvarput1 (int ncid, int varid, const long *indexp, const void *op) | 
| EXTERNL int | ncvarget1 (int ncid, int varid, const long *indexp, void *ip) | 
| EXTERNL int | ncvarput (int ncid, int varid, const long *startp, const long *countp, const void *op) | 
| EXTERNL int | ncvarget (int ncid, int varid, const long *startp, const long *countp, void *ip) | 
| EXTERNL int | ncvarputs (int ncid, int varid, const long *startp, const long *countp, const long *stridep, const void *op) | 
| EXTERNL int | ncvargets (int ncid, int varid, const long *startp, const long *countp, const long *stridep, void *ip) | 
| EXTERNL int | ncvarputg (int ncid, int varid, const long *startp, const long *countp, const long *stridep, const long *imapp, const void *op) | 
| EXTERNL int | ncvargetg (int ncid, int varid, const long *startp, const long *countp, const long *stridep, const long *imapp, void *ip) | 
| EXTERNL int | ncvarrename (int ncid, int varid, const char *name) | 
| EXTERNL int | ncrecinq (int ncid, int *nrecvarsp, int *recvaridsp, long *recsizesp) | 
| EXTERNL int | ncrecget (int ncid, long recnum, void **datap) | 
| EXTERNL int | ncrecput (int ncid, long recnum, void *const *datap) | 
| Variables | |
| EXTERNL int | ncerr | 
| EXTERNL int | ncopts | 
Define Documentation
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
Typedef Documentation
| 
 | 
| 
 | 
Enumeration Type Documentation
| 
 | 
| 
 Definition at line 47 of file netcdf.h. 
 00047              {
00048         NC_NAT =        0,      /* NAT = 'Not A Type' (c.f. NaN) */
00049         NC_BYTE =       1,      /* signed 1 byte integer */
00050         NC_CHAR =       2,      /* ISO/ASCII character */
00051         NC_SHORT =      3,      /* signed 2 byte integer */
00052         NC_INT =        4,      /* signed 4 byte integer */
00053         NC_FLOAT =      5,      /* single precision floating point number */
00054         NC_DOUBLE =     6       /* double precision floating point number */
00055 } nc_type;
 | 
Function Documentation
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 736 of file nc.c. References nc__create_mp(). Referenced by main(), and nc_create(). 
 00738 {
00739         return nc__create_mp(path, ioflags, initialsz, 0,
00740                 chunksizehintp, ncid_ptr);
00741 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 744 of file nc.c. References add_to_NCList(), NC::chunk, ncio::fd, fIsSet, NC::flags, free_NC(), fSet, ncio::ioflags, NC_CREAT, NC_NSYNC, ncio_close(), ncio_create(), NC::nciop, ncx_put_NC(), new_NC(), and NC::xsz. Referenced by nc__create(). 
 00746 {
00747         NC *ncp;
00748         int status;
00749         void *xp = NULL;
00750 
00751 #if ALWAYS_NC_SHARE /* DEBUG */
00752         fSet(ioflags, NC_SHARE);
00753 #endif
00754 
00755         ncp = new_NC(chunksizehintp);
00756         if(ncp == NULL)
00757                 return NC_ENOMEM;
00758 
00759 #if defined(LOCKNUMREC) /* && _CRAYMPP */
00760         if (status = NC_init_pe(ncp, basepe)) {
00761                 return status;
00762         }
00763 #else
00764         /*
00765          * !_CRAYMPP, only pe 0 is valid
00766          */
00767         if(basepe != 0)
00768                 return NC_EINVAL;
00769 #endif
00770         assert(ncp->xsz == ncx_len_NC(ncp));
00771         
00772         status = ncio_create(path, ioflags,
00773                 initialsz,
00774                 0, ncp->xsz, &ncp->chunk,
00775                 &ncp->nciop, &xp);
00776         if(status != NC_NOERR)
00777         {
00778                 /* translate error status */
00779                 if(status == EEXIST)
00780                         status = NC_EEXIST;
00781                 goto unwind_alloc;
00782         }
00783 
00784         assert(ncp->flags == 0);
00785         fSet(ncp->flags, NC_CREAT);
00786 
00787         if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
00788         {
00789                 /*
00790                  * NC_SHARE implies sync up the number of records as well.
00791                  * (File format version one.)
00792                  * Note that other header changes are not shared
00793                  * automatically.  Some sort of IPC (external to this package)
00794                  * would be used to trigger a call to nc_sync().
00795                  */
00796                 fSet(ncp->flags, NC_NSYNC);
00797         }
00798 
00799         status = ncx_put_NC(ncp, &xp, 0, ncp->xsz);
00800         if(status != NC_NOERR)
00801                 goto unwind_ioc;
00802 
00803         add_to_NCList(ncp);
00804 
00805         if(chunksizehintp != NULL)
00806                 *chunksizehintp = ncp->chunk;
00807         *ncid_ptr = ncp->nciop->fd;
00808         return NC_NOERR;
00809 
00810 unwind_ioc:
00811         (void) ncio_close(ncp->nciop, 1); /* N.B.: unlink */
00812         ncp->nciop = NULL;
00813         /*FALLTHRU*/
00814 unwind_alloc:
00815         free_NC(ncp);
00816         return status;
00817 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 908 of file nc.c. References NC_check_id(), NC_endef(), and NC_indef. Referenced by main(). 
 00911 {
00912         int status;
00913         NC *ncp;
00914 
00915         status = NC_check_id(ncid, &ncp); 
00916         if(status != NC_NOERR)
00917                 return status;
00918 
00919         if(!NC_indef(ncp))
00920                 return(NC_ENOTINDEFINE);
00921 
00922         return (NC_endef(ncp, h_minfree, v_align, v_minfree, r_align));
00923 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 827 of file nc.c. References nc__open_mp(). Referenced by main(), and nc_open(). 
 00829 {
00830         return nc__open_mp(path, ioflags, 0,
00831                 chunksizehintp, ncid_ptr);
00832 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 835 of file nc.c. References add_to_NCList(), NC::chunk, ncio::fd, fIsSet, NC::flags, free_NC(), fSet, ncio::ioflags, nc_get_NC(), NC_NSYNC, ncio_close(), ncio_open(), NC::nciop, and new_NC(). Referenced by nc__open(). 
 00837 {
00838         NC *ncp;
00839         int status;
00840 
00841 #if ALWAYS_NC_SHARE /* DEBUG */
00842         fSet(ioflags, NC_SHARE);
00843 #endif
00844 
00845         ncp = new_NC(chunksizehintp);
00846         if(ncp == NULL)
00847                 return NC_ENOMEM;
00848 
00849 #if defined(LOCKNUMREC) /* && _CRAYMPP */
00850         if (status = NC_init_pe(ncp, basepe)) {
00851                 return status;
00852         }
00853 #else
00854         /*
00855          * !_CRAYMPP, only pe 0 is valid
00856          */
00857         if(basepe != 0)
00858                 return NC_EINVAL;
00859 #endif
00860         status = ncio_open(path, ioflags,
00861                 0, 0, &ncp->chunk,
00862                 &ncp->nciop, 0);
00863         if(status)
00864                 goto unwind_alloc;
00865 
00866         assert(ncp->flags == 0);
00867 
00868         if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
00869         {
00870                 /*
00871                  * NC_SHARE implies sync up the number of records as well.
00872                  * (File format version one.)
00873                  * Note that other header changes are not shared
00874                  * automatically.  Some sort of IPC (external to this package)
00875                  * would be used to trigger a call to nc_sync().
00876                  */
00877                 fSet(ncp->flags, NC_NSYNC);
00878         }
00879 
00880         status = nc_get_NC(ncp);
00881         if(status != NC_NOERR)
00882                 goto unwind_ioc;
00883 
00884         add_to_NCList(ncp);
00885 
00886         if(chunksizehintp != NULL)
00887                 *chunksizehintp = ncp->chunk;
00888         *ncid_ptr = ncp->nciop->fd;
00889         return NC_NOERR;
00890 
00891 unwind_ioc:
00892         (void) ncio_close(ncp->nciop, 0);
00893         ncp->nciop = NULL;
00894         /*FALLTHRU*/
00895 unwind_alloc:
00896         free_NC(ncp);
00897         return status;
00898 }
 | 
| 
 | 
| 
 Definition at line 1040 of file nc.c. References del_from_NCList(), fClr, fIsSet, NC::flags, free_NC(), NC_check_id(), NC_INDEF, NC_IsNew, NC_readonly, NC_sync(), ncio_close(), NC::nciop, and NC::old. Referenced by nc_close(), and ncabort(). 
 01041 {
01042         int status;
01043         NC *ncp;
01044         int doUnlink = 0;
01045 
01046         status = NC_check_id(ncid, &ncp); 
01047         if(status != NC_NOERR)
01048                 return status;
01049 
01050         doUnlink = NC_IsNew(ncp);
01051 
01052         if(ncp->old != NULL)
01053         {
01054                 /* a plain redef, not a create */
01055                 assert(!NC_IsNew(ncp));
01056                 assert(fIsSet(ncp->flags, NC_INDEF));
01057                 free_NC(ncp->old);
01058                 ncp->old = NULL;
01059                 fClr(ncp->flags, NC_INDEF);
01060         }
01061         else if(!NC_readonly(ncp))
01062         {
01063                 status = NC_sync(ncp);
01064                 if(status != NC_NOERR)
01065                         return status;
01066         }
01067 
01068 
01069         (void) ncio_close(ncp->nciop, doUnlink);
01070         ncp->nciop = NULL;
01071 
01072         del_from_NCList(ncp);
01073 
01074         free_NC(ncp);
01075 
01076         return NC_NOERR;
01077 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 103 of file v2i.c. References args, NC_ISSYSERR, nc_strerror(), ncerr, and ncopts. Referenced by has_c_format_att(), ncabort(), NCadvise(), ncattcopy(), ncattdel(), ncattget(), ncattinq(), ncattname(), ncattput(), ncattrename(), ncclose(), nccreate(), ncdimdef(), ncdimid(), ncdiminq(), ncdimrename(), ncendef(), ncinquire(), ncopen(), ncrecget(), ncrecinq(), ncrecput(), ncredef(), ncsetfill(), ncsync(), nctypelen(), ncvardef(), ncvarget(), ncvarget1(), ncvargetg(), ncvargets(), ncvarid(), ncvarinq(), ncvarput(), ncvarput1(), ncvarputg(), ncvarputs(), and ncvarrename(). 
 00104 {
00105         va_list args;
00106 
00107         if(NC_ISSYSERR(err))
00108                 ncerr = NC_SYSERR;
00109         else
00110                 ncerr = err;
00111 
00112         if( ncopts & NC_VERBOSE )
00113         {
00114                 (void) fprintf(stderr,"%s: ", routine_name);
00115                 va_start(args ,fmt);
00116                 (void) vfprintf(stderr,fmt,args);
00117                 va_end(args);
00118                 if(err != NC_NOERR)
00119                 {
00120                         (void) fprintf(stderr,": %s",
00121                                 nc_strerror(err));
00122                 }
00123                 (void) fputc('\n',stderr);
00124                 (void) fflush(stderr);  /* to ensure log files are current */
00125         }
00126 
00127         if( (ncopts & NC_FATAL) && err != NC_NOERR )
00128         {
00129                 exit(ncopts);
00130         }
00131 }
 | 
| 
 | 
| 
 Definition at line 944 of file nc.c. References del_from_NCList(), free_NC(), nc_abort(), NC_check_id(), NC_endef(), NC_indef, NC_readonly, NC_sync(), ncio_close(), and NC::nciop. Referenced by do_ncdump(), main(), ncclose(), pr_att(), THD_load_minc(), and THD_open_minc(). 
 00945 {
00946         int status = NC_NOERR;
00947         NC *ncp; 
00948 
00949         status = NC_check_id(ncid, &ncp); 
00950         if(status != NC_NOERR)
00951                 return status;
00952 
00953         if(NC_indef(ncp))
00954         {
00955                 status = NC_endef(ncp, 0, 1, 0, 1); /* TODO: defaults */
00956                 if(status != NC_NOERR )
00957                 {
00958                         (void) nc_abort(ncid);
00959                         return status;
00960                 }
00961         }
00962         else if(!NC_readonly(ncp))
00963         {
00964                 status = NC_sync(ncp);
00965         }
00966 
00967         (void) ncio_close(ncp->nciop, 0);
00968         ncp->nciop = NULL;
00969 
00970         del_from_NCList(ncp);
00971 
00972         free_NC(ncp);
00973 
00974         return status;
00975 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 555 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_doHsync, NC_findattr(), NC_indef, NC_lookupattr(), NC_readonly, NC_sync(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by ncattcopy(). 
 00556 {
00557         int status;
00558         NC_attr *iattrp;
00559         NC *ncp;
00560         NC_attrarray *ncap;
00561         NC_attr **attrpp;
00562         NC_attr *old = NULL;
00563         NC_attr *attrp;
00564 
00565         status = NC_lookupattr(ncid_in, varid_in, name, &iattrp);
00566         if(status != NC_NOERR)
00567                 return status;
00568 
00569         status = NC_check_id(ncid_out, &ncp);
00570         if(status != NC_NOERR)
00571                 return status;
00572 
00573         if(NC_readonly(ncp))
00574                 return NC_EPERM;
00575 
00576         ncap = NC_attrarray0(ncp, ovarid);
00577         if(ncap == NULL)
00578                 return NC_ENOTVAR;
00579 
00580         attrpp = NC_findattr(ncap, name);
00581         if(attrpp != NULL) /* name in use */
00582         {
00583                 if(!NC_indef(ncp) )
00584                 {
00585                         attrp = *attrpp; /* convenience */
00586         
00587                         if(iattrp->xsz > attrp->xsz)
00588                                 return NC_ENOTINDEFINE;
00589                         /* else, we can reuse existing without redef */
00590                         
00591                         attrp->xsz = iattrp->xsz;
00592                         attrp->type = iattrp->type;
00593                         attrp->nelems = iattrp->nelems;
00594 
00595                         (void) memcpy(attrp->xvalue, iattrp->xvalue,
00596                                 iattrp->xsz);
00597                         
00598                         set_NC_hdirty(ncp);
00599 
00600                         if(NC_doHsync(ncp))
00601                         {
00602                                 status = NC_sync(ncp);
00603                                 if(status != NC_NOERR)
00604                                         return status;
00605                         }
00606 
00607                         return NC_NOERR;
00608                 }
00609                 /* else, redefine using existing array slot */
00610                 old = *attrpp;
00611         } 
00612         else
00613         {
00614                 if(!NC_indef(ncp))
00615                         return NC_ENOTINDEFINE;
00616 
00617                 if(ncap->nelems >= NC_MAX_ATTRS)
00618                         return NC_EMAXATTS;
00619         }
00620 
00621         attrp = new_NC_attr(name, iattrp->type, iattrp->nelems);
00622         if(attrp == NULL)
00623                 return NC_ENOMEM;
00624 
00625         (void) memcpy(attrp->xvalue, iattrp->xvalue,
00626                 iattrp->xsz);
00627 
00628         if(attrpp != NULL)
00629         {
00630                 assert(old != NULL);
00631                 *attrpp = attrp;
00632                 free_NC_attr(old);
00633         }
00634         else
00635         {
00636                 status = incr_NC_attrarray(ncap, attrp);
00637                 if(status != NC_NOERR)
00638                 {
00639                         free_NC_attr(attrp);
00640                         return status;
00641                 }
00642         }
00643 
00644         return NC_NOERR;
00645 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 11665 of file putget.c. References ALLOC_ONSTACK, NC_string::cp, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_var::name, NC_check_id(), NC_findvar(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), NCxvarcpy(), NC_var::ndims, NC_var::shape, NC_var::type, and NC::vars. 
 11666 {
11667         int status = NC_NOERR;
11668         NC *inncp, *outncp;
11669         NC_var *invp, *outvp;
11670 
11671         status = NC_check_id(ncid_in, &inncp); 
11672         if(status != NC_NOERR)
11673                 return status;
11674 
11675 
11676         if(NC_indef(inncp))
11677         {
11678                 return NC_EINDEFINE;
11679         }
11680 
11681         status = NC_check_id(ncid_out, &outncp); 
11682         if(status != NC_NOERR)
11683                 return status;
11684 
11685         if(NC_readonly(outncp))
11686         {
11687                 /* output file isn't writable */
11688                 return NC_EPERM;
11689         }
11690 
11691         if(NC_indef(outncp))
11692         {
11693                 return NC_EINDEFINE;
11694         }
11695 
11696         /* find the variable in the input cdf */
11697         invp = NC_lookupvar(inncp, varid);
11698         if(invp == NULL)
11699         {
11700                 return NC_ENOTVAR;
11701         }
11702 
11703         /* find the variable in the output cdf */
11704         if(NC_findvar(&outncp->vars, invp->name->cp, &outvp) == -1)
11705         {
11706                 return NC_ENOTVAR;
11707         }
11708 
11709         /* can we even attempt to copy without conversion? */
11710         if(outvp->type != invp->type)
11711         {
11712                 return NC_EINVAL;
11713         }
11714 
11715         if(        (invp->ndims == 0 && outvp->ndims != 0)
11716                 || (invp->ndims != 0 && outvp->ndims == 0)
11717                 || (IS_RECVAR(invp) && !IS_RECVAR(outvp))
11718                 || (!IS_RECVAR(invp) && IS_RECVAR(outvp))
11719                 || (invp->len != outvp->len)
11720         )
11721         {
11722                 return NC_EINVAL;
11723         }
11724 
11725         /*
11726          * Check coordinates
11727          */
11728         {
11729         ALLOC_ONSTACK(coord, size_t, invp->ndims);
11730         const size_t nrecs = NC_get_numrecs(inncp);
11731         (void) memcpy(coord, invp->shape, invp->ndims * sizeof(size_t));
11732         if(IS_RECVAR(invp))
11733                 *coord = nrecs;
11734         
11735         {
11736         size_t ii = 0;
11737         for(; ii < invp->ndims; ii++)
11738                 coord[ii] --;
11739         }
11740         /* at this point, coord is the largest valid coord of invp */
11741 
11742         if(NCcoordck(outncp, outvp, coord) != NC_NOERR)
11743         {
11744                 return NC_EINVAL;
11745         }
11746         /* else */
11747 
11748         (void) memset(coord, 0, invp->ndims * sizeof(size_t));
11749         
11750         if(!IS_RECVAR(invp))
11751         {
11752                 status = NCxvarcpy(inncp, invp, coord,
11753                                 outncp, outvp, coord,
11754                                 invp->len);
11755                 goto done;
11756         }
11757         /* else */
11758 
11759         status = NCvnrecs(outncp, nrecs);
11760         if(status != NC_NOERR)
11761                 goto done;
11762 
11763         for( /*NADA*/; *coord < nrecs; (*coord)++)
11764         {
11765                 status = NCxvarcpy(inncp, invp, coord,
11766                                 outncp, outvp, coord,
11767                                 invp->len);
11768                 if(status != NC_NOERR)
11769                         break;
11770         }
11771 done:
11772         FREE_ONSTACK(coord);
11773         }
11774         return status;
11775 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 820 of file nc.c. References nc__create(). Referenced by nccreate(). 
 00821 {
00822         return nc__create(path, ioflags, 0, NULL, ncid_ptr);
00823 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 305 of file dim.c. References NC::dims, find_NC_Udim(), free_NC_dim(), incr_NC_dimarray(), name, NC_check_id(), NC_check_name(), NC_finddim(), NC_indef, NC_dimarray::nelems, and new_NC_dim(). Referenced by createtestdims(), and ncdimdef(). 
 00306 {
00307         int status;
00308         NC *ncp;
00309         int dimid;
00310         NC_dim *dimp;
00311 
00312         status = NC_check_id(ncid, &ncp); 
00313         if(status != NC_NOERR)
00314                 return status;
00315 
00316         if(!NC_indef(ncp))
00317                 return NC_ENOTINDEFINE;
00318 
00319         status = NC_check_name(name);
00320         if(status != NC_NOERR)
00321                 return status;
00322 
00323                 /* cast needed for braindead systems with signed size_t */
00324         if((unsigned long) size > X_INT_MAX) /* Backward compat */
00325                 return NC_EINVAL;
00326 
00327         if(size == NC_UNLIMITED)
00328         {
00329                 dimid = find_NC_Udim(&ncp->dims, &dimp);
00330                 if(dimid != -1)
00331                 {
00332                         assert(dimid != -1);
00333                         return NC_EUNLIMIT;
00334                 }
00335         }
00336 
00337         if(ncp->dims.nelems >= NC_MAX_DIMS)
00338                 return NC_EMAXDIMS;
00339 
00340         dimid = NC_finddim(&ncp->dims, name, &dimp);
00341         if(dimid != -1)
00342                 return NC_ENAMEINUSE;
00343         
00344         dimp = new_NC_dim(name, size);
00345         if(dimp == NULL)
00346                 return NC_ENOMEM;
00347         status = incr_NC_dimarray(&ncp->dims, dimp);
00348         if(status != NC_NOERR)
00349         {
00350                 free_NC_dim(dimp);
00351                 return status;
00352         }
00353 
00354         if(dimidp != NULL)
00355                 *dimidp = (int)ncp->dims.nelems -1;
00356         return NC_NOERR;
00357 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 460 of file var.c. References NC::dims, free_NC_var(), incr_NC_vararray(), name, NC_check_id(), NC_check_name(), nc_cktype(), NC_findvar(), NC_indef, NC_var_shape(), ndims, NC_vararray::nelems, new_NC_var(), and NC::vars. Referenced by createtestvars(), and ncvardef(). 
 00462 {
00463         int status;
00464         NC *ncp;
00465         int varid;
00466         NC_var *varp;
00467 
00468         status = NC_check_id(ncid, &ncp); 
00469         if(status != NC_NOERR)
00470                 return status;
00471 
00472         if(!NC_indef(ncp))
00473         {
00474                 return NC_ENOTINDEFINE;
00475         }
00476 
00477         status = NC_check_name(name);
00478         if(status != NC_NOERR)
00479                 return status;
00480 
00481         status = nc_cktype(type);
00482         if(status != NC_NOERR)
00483                 return status;
00484 
00485                 /* cast needed for braindead systems with signed size_t */
00486         if((unsigned long) ndims > X_INT_MAX) /* Backward compat */
00487         {
00488                 return NC_EINVAL;
00489         } 
00490 
00491         if(ncp->vars.nelems >= NC_MAX_VARS)
00492         {
00493                 return NC_EMAXVARS;
00494         }
00495 
00496         varid = NC_findvar(&ncp->vars, name, &varp);
00497         if(varid != -1)
00498         {
00499                 return NC_ENAMEINUSE;
00500         }
00501         
00502         varp = new_NC_var(name, type, ndims, dimids);
00503         if(varp == NULL)
00504                 return NC_ENOMEM;
00505 
00506         status = NC_var_shape(varp, &ncp->dims);
00507         if(status != NC_NOERR)
00508         {
00509                 free_NC_var(varp);
00510                 return status;
00511         }
00512 
00513         status = incr_NC_vararray(&ncp->vars, varp);
00514         if(status != NC_NOERR)
00515         {
00516                 free_NC_var(varp);
00517                 return status;
00518         }
00519 
00520         if(varidp != NULL)
00521                 *varidp = (int)ncp->vars.nelems -1; /* varid */
00522         return NC_NOERR;
00523 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 649 of file attr.c. References free_NC_attr(), name, NC_attrarray0(), NC_check_id(), NC_indef, NC_attrarray::nelems, and NC_attrarray::value. Referenced by main(), and ncattdel(). 
 00650 {
00651         int status;
00652         NC *ncp;
00653         NC_attrarray *ncap;
00654         NC_attr **attrpp;
00655         NC_attr *old = NULL;
00656         int attrid;
00657         size_t slen;
00658 
00659         status = NC_check_id(ncid, &ncp);
00660         if(status != NC_NOERR)
00661                 return status;
00662 
00663         if(!NC_indef(ncp))
00664                 return NC_ENOTINDEFINE;
00665 
00666         ncap = NC_attrarray0(ncp, varid);
00667         if(ncap == NULL)
00668                 return NC_ENOTVAR;
00669 
00670                         /* sortof inline NC_findattr() */
00671         slen = strlen(name);
00672 
00673         attrpp = (NC_attr **) ncap->value;
00674         for(attrid = 0; (size_t) attrid < ncap->nelems; attrid++, attrpp++)
00675         {
00676                 if( slen == (*attrpp)->name->nchars &&
00677                         strncmp(name, (*attrpp)->name->cp, slen) == 0)
00678                 {
00679                         old = *attrpp;
00680                         break;
00681                 }
00682         }
00683         if( (size_t) attrid == ncap->nelems )
00684                 return NC_ENOTATT;
00685                         /* end inline NC_findattr() */
00686 
00687         /* shuffle down */
00688         for(attrid++; (size_t) attrid < ncap->nelems; attrid++)
00689         {
00690                 *attrpp = *(attrpp + 1);
00691                 attrpp++;
00692         }
00693         *attrpp = NULL;
00694         /* decrement count */
00695         ncap->nelems--;
00696 
00697         free_NC_attr(old);
00698 
00699         return NC_NOERR;
00700 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 985 of file nc.c. References NC::chunk, NC::flags, free_NC(), nc_get_NC(), ncio_close(), ncio_open(), NC::nciop, and new_NC(). Referenced by nc_delete(). 
 00986 {
00987         NC *ncp;
00988         int status;
00989         size_t chunk = 512;
00990 
00991         ncp = new_NC(&chunk);
00992         if(ncp == NULL)
00993                 return NC_ENOMEM;
00994         
00995 #if defined(LOCKNUMREC) /* && _CRAYMPP */
00996         if (status = NC_init_pe(ncp, basepe)) {
00997                 return status;
00998         }
00999 #else
01000         /*
01001          * !_CRAYMPP, only pe 0 is valid
01002          */
01003         if(basepe != 0)
01004                 return NC_EINVAL;
01005 #endif
01006         status = ncio_open(path, NC_NOWRITE,
01007                 0, 0, &ncp->chunk,
01008                 &ncp->nciop, 0);
01009         if(status)
01010                 goto unwind_alloc;
01011 
01012         assert(ncp->flags == 0);
01013 
01014         status = nc_get_NC(ncp);
01015         if(status != NC_NOERR)
01016         {
01017                 /* Not a netcdf file, don't delete */
01018                 /* ??? is this the right semantic? what if it was just too big? */
01019                 (void) ncio_close(ncp->nciop, 0);
01020         }
01021         else
01022         {
01023                 /* ncio_close does the unlink */
01024                 status = ncio_close(ncp->nciop, 1); /* ncio_close does the unlink */
01025         }
01026 
01027         ncp->nciop = NULL;
01028 unwind_alloc:
01029         free_NC(ncp);
01030         return status;
01031 }
 | 
| 
 | 
| 
 Definition at line 926 of file nc.c. References NC_check_id(), NC_endef(), and NC_indef. Referenced by ncendef(). 
 00927 {
00928         int status;
00929         NC *ncp;
00930 
00931         status = NC_check_id(ncid, &ncp); 
00932         if(status != NC_NOERR)
00933                 return status;
00934 
00935         if(!NC_indef(ncp))
00936                 return(NC_ENOTINDEFINE);
00937 
00938         /* return(NC_endef(ncp, 0, 4096, 0, 4096)); */
00939         return (NC_endef(ncp, 0, 1, 0, 1));
00940 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2150 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Idouble(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by do_ncdump(), main(), nc_get_att(), and pr_att(). 
 02151 {
02152         int status;
02153         NC_attr *attrp;
02154 
02155         status = NC_lookupattr(ncid, varid, name, &attrp);
02156         if(status != NC_NOERR)
02157                 return status;
02158 
02159         if(attrp->nelems == 0)
02160                 return NC_NOERR;
02161 
02162         if(attrp->type == NC_CHAR)
02163                 return NC_ECHAR;
02164 
02165         {
02166         const void *xp = attrp->xvalue;
02167         return ncx_pad_getn_Idouble(&xp, attrp->nelems, tp, attrp->type);
02168         }
02169 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2003 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Ifloat(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by nc_get_att(), read_mincdim(), THD_load_minc(), and THD_open_minc(). 
 02004 {
02005         int status;
02006         NC_attr *attrp;
02007 
02008         status = NC_lookupattr(ncid, varid, name, &attrp);
02009         if(status != NC_NOERR)
02010                 return status;
02011 
02012         if(attrp->nelems == 0)
02013                 return NC_NOERR;
02014 
02015         if(attrp->type == NC_CHAR)
02016                 return NC_ECHAR;
02017 
02018         {
02019         const void *xp = attrp->xvalue;
02020         return ncx_pad_getn_Ifloat(&xp, attrp->nelems, tp, attrp->type);
02021         }
02022 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1709 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Iint(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by nc_get_att(). 
 01710 {
01711         int status;
01712         NC_attr *attrp;
01713 
01714         status = NC_lookupattr(ncid, varid, name, &attrp);
01715         if(status != NC_NOERR)
01716                 return status;
01717 
01718         if(attrp->nelems == 0)
01719                 return NC_NOERR;
01720 
01721         if(attrp->type == NC_CHAR)
01722                 return NC_ECHAR;
01723 
01724         {
01725         const void *xp = attrp->xvalue;
01726         return ncx_pad_getn_Iint(&xp, attrp->nelems, tp, attrp->type);
01727         }
01728 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1856 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Ilong(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by nc_get_att(). 
 01857 {
01858         int status;
01859         NC_attr *attrp;
01860 
01861         status = NC_lookupattr(ncid, varid, name, &attrp);
01862         if(status != NC_NOERR)
01863                 return status;
01864 
01865         if(attrp->nelems == 0)
01866                 return NC_NOERR;
01867 
01868         if(attrp->type == NC_CHAR)
01869                 return NC_ECHAR;
01870 
01871         {
01872         const void *xp = attrp->xvalue;
01873         return ncx_pad_getn_Ilong(&xp, attrp->nelems, tp, attrp->type);
01874         }
01875 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1268 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Ischar(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by nc_get_att(). 
 01269 {
01270         int status;
01271         NC_attr *attrp;
01272 
01273         status = NC_lookupattr(ncid, varid, name, &attrp);
01274         if(status != NC_NOERR)
01275                 return status;
01276 
01277         if(attrp->nelems == 0)
01278                 return NC_NOERR;
01279 
01280         if(attrp->type == NC_CHAR)
01281                 return NC_ECHAR;
01282 
01283         {
01284         const void *xp = attrp->xvalue;
01285         return ncx_pad_getn_Ischar(&xp, attrp->nelems, tp, attrp->type);
01286         }
01287 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1562 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Ishort(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by nc_get_att(). 
 01563 {
01564         int status;
01565         NC_attr *attrp;
01566 
01567         status = NC_lookupattr(ncid, varid, name, &attrp);
01568         if(status != NC_NOERR)
01569                 return status;
01570 
01571         if(attrp->nelems == 0)
01572                 return NC_NOERR;
01573 
01574         if(attrp->type == NC_CHAR)
01575                 return NC_ECHAR;
01576 
01577         {
01578         const void *xp = attrp->xvalue;
01579         return ncx_pad_getn_Ishort(&xp, attrp->nelems, tp, attrp->type);
01580         }
01581 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1118 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_text(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. Referenced by do_ncdump(), has_c_format_att(), main(), nc_get_att(), pr_att(), read_mincdim(), and THD_open_minc(). 
 01119 {
01120         int status;
01121         NC_attr *attrp;
01122 
01123         status = NC_lookupattr(ncid, varid, name, &attrp);
01124         if(status != NC_NOERR)
01125                 return status;
01126 
01127         if(attrp->nelems == 0)
01128                 return NC_NOERR;
01129 
01130         if(attrp->type != NC_CHAR)
01131                 return NC_ECHAR;
01132 
01133         /* else */
01134         {
01135                 const void *xp = attrp->xvalue;
01136                 return ncx_pad_getn_text(&xp, attrp->nelems, str);
01137         }
01138 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 1415 of file attr.c. References name, NC_lookupattr(), ncx_pad_getn_Iuchar(), NC_attr::nelems, NC_attr::type, and NC_attr::xvalue. 
 01416 {
01417         int status;
01418         NC_attr *attrp;
01419 
01420         status = NC_lookupattr(ncid, varid, name, &attrp);
01421         if(status != NC_NOERR)
01422                 return status;
01423 
01424         if(attrp->nelems == 0)
01425                 return NC_NOERR;
01426 
01427         if(attrp->type == NC_CHAR)
01428                 return NC_ECHAR;
01429 
01430         {
01431         const void *xp = attrp->xvalue;
01432         return ncx_pad_getn_Iuchar(&xp, attrp->nelems, tp, attrp->type);
01433         }
01434 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4890 of file putget.c. References getNCv_double(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. Referenced by main(), and nc_get_var1(). 
 04891 {
04892         int status;
04893         NC *ncp;
04894         const NC_var *varp;
04895 
04896         status = NC_check_id(ncid, &ncp); 
04897         if(status != NC_NOERR)
04898                 return status;
04899 
04900         if(NC_indef(ncp))
04901                 return NC_EINDEFINE;
04902 
04903         varp = NC_lookupvar(ncp, varid);
04904         if(varp == NULL)
04905                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04906 
04907         if(varp->type == NC_CHAR)
04908                 return NC_ECHAR;
04909 
04910         status = NCcoordck(ncp, varp, coord);
04911         if(status != NC_NOERR)
04912                 return status;
04913 
04914         return getNCv_double(ncp, varp, coord, 1, value);
04915 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4862 of file putget.c. References getNCv_float(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. Referenced by check_fill_seq(), main(), and nc_get_var1(). 
 04863 {
04864         int status;
04865         NC *ncp;
04866         const NC_var *varp;
04867 
04868         status = NC_check_id(ncid, &ncp); 
04869         if(status != NC_NOERR)
04870                 return status;
04871 
04872         if(NC_indef(ncp))
04873                 return NC_EINDEFINE;
04874 
04875         varp = NC_lookupvar(ncp, varid);
04876         if(varp == NULL)
04877                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04878 
04879         if(varp->type == NC_CHAR)
04880                 return NC_ECHAR;
04881 
04882         status = NCcoordck(ncp, varp, coord);
04883         if(status != NC_NOERR)
04884                 return status;
04885 
04886         return getNCv_float(ncp, varp, coord, 1, value);
04887 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4806 of file putget.c. References getNCv_int(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. Referenced by main(), and nc_get_var1(). 
 04807 {
04808         int status;
04809         NC *ncp;
04810         const NC_var *varp;
04811 
04812         status = NC_check_id(ncid, &ncp); 
04813         if(status != NC_NOERR)
04814                 return status;
04815 
04816         if(NC_indef(ncp))
04817                 return NC_EINDEFINE;
04818 
04819         varp = NC_lookupvar(ncp, varid);
04820         if(varp == NULL)
04821                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04822 
04823         if(varp->type == NC_CHAR)
04824                 return NC_ECHAR;
04825 
04826         status = NCcoordck(ncp, varp, coord);
04827         if(status != NC_NOERR)
04828                 return status;
04829 
04830         return getNCv_int(ncp, varp, coord, 1, value);
04831 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4834 of file putget.c. References getNCv_long(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. 
 04835 {
04836         int status;
04837         NC *ncp;
04838         const NC_var *varp;
04839 
04840         status = NC_check_id(ncid, &ncp); 
04841         if(status != NC_NOERR)
04842                 return status;
04843 
04844         if(NC_indef(ncp))
04845                 return NC_EINDEFINE;
04846 
04847         varp = NC_lookupvar(ncp, varid);
04848         if(varp == NULL)
04849                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04850 
04851         if(varp->type == NC_CHAR)
04852                 return NC_ECHAR;
04853 
04854         status = NCcoordck(ncp, varp, coord);
04855         if(status != NC_NOERR)
04856                 return status;
04857 
04858         return getNCv_long(ncp, varp, coord, 1, value);
04859 }
 | 
| 
 | ||||||||||||||||||||
| 
 Referenced by main(), and nc_get_var1(). | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4778 of file putget.c. References getNCv_short(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. Referenced by main(), and nc_get_var1(). 
 04779 {
04780         int status;
04781         NC *ncp;
04782         const NC_var *varp;
04783 
04784         status = NC_check_id(ncid, &ncp); 
04785         if(status != NC_NOERR)
04786                 return status;
04787 
04788         if(NC_indef(ncp))
04789                 return NC_EINDEFINE;
04790 
04791         varp = NC_lookupvar(ncp, varid);
04792         if(varp == NULL)
04793                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04794 
04795         if(varp->type == NC_CHAR)
04796                 return NC_ECHAR;
04797 
04798         status = NCcoordck(ncp, varp, coord);
04799         if(status != NC_NOERR)
04800                 return status;
04801 
04802         return getNCv_short(ncp, varp, coord, 1, value);
04803 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4693 of file putget.c. References getNCv_text(), NC_check_id(), NC_indef, NC_lookupvar(), NCcoordck(), and NC_var::type. Referenced by main(), and nc_get_var1(). 
 04694 {
04695         int status;
04696         NC *ncp;
04697         const NC_var *varp;
04698 
04699         status = NC_check_id(ncid, &ncp); 
04700         if(status != NC_NOERR)
04701                 return status;
04702 
04703         if(NC_indef(ncp))
04704                 return NC_EINDEFINE;
04705 
04706         varp = NC_lookupvar(ncp, varid);
04707         if(varp == NULL)
04708                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04709 
04710         if(varp->type != NC_CHAR)
04711                 return NC_ECHAR;
04712 
04713         status = NCcoordck(ncp, varp, coord);
04714         if(status != NC_NOERR)
04715                 return status;
04716 
04717         return getNCv_text(ncp, varp, coord, 1, value);
04718 }
 | 
| 
 | ||||||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7881 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_double(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. Referenced by main(). 
 07882 {
07883         int status = NC_NOERR;
07884         NC *ncp;
07885         const NC_var *varp;
07886 
07887         status = NC_check_id(ncid, &ncp); 
07888         if(status != NC_NOERR)
07889                 return status;
07890 
07891         if(NC_indef(ncp))
07892                 return NC_EINDEFINE;
07893 
07894         varp = NC_lookupvar(ncp, varid);
07895         if(varp == NULL)
07896                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07897 
07898         if(varp->ndims == 0) /* scalar variable */
07899         {
07900                 const size_t zed = 0;
07901                 return( getNCv_double(ncp, varp, &zed, 1, value) );
07902         }
07903 
07904         if(varp->type == NC_CHAR)
07905                 return NC_ECHAR;
07906 
07907 
07908         if(!IS_RECVAR(varp))
07909         {
07910                 return(getNCv_double(ncp, varp, coord_zero, *varp->dsizes, value));
07911         }
07912         /* else */
07913 
07914         if(varp->ndims == 1
07915                         && ncp->recsize <= varp->len)
07916         {
07917                 /* one dimensional && the only record variable  */
07918                 return(getNCv_double(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07919                         value));
07920         }
07921         /* else */
07922 
07923         {
07924         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07925         size_t elemsPerRec = 1;
07926         const size_t nrecs = NC_get_numrecs(ncp);
07927         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07928         /* TODO: fix dsizes to avoid this nonsense */
07929         if(varp->ndims > 1)
07930                 elemsPerRec = varp->dsizes[1];
07931         while(*coord < nrecs)
07932         {
07933                 const int lstatus = getNCv_double(ncp, varp, coord, elemsPerRec,
07934                                 value);
07935                 if(lstatus != NC_NOERR)
07936                 {
07937                         if(lstatus != NC_ERANGE)
07938                         {
07939                                 status = lstatus;
07940                                 /* fatal for the loop */
07941                                 break;
07942                         }
07943                         /* else NC_ERANGE, not fatal for the loop */
07944                         if(status == NC_NOERR)
07945                                 status = lstatus;
07946                 }
07947                 value += elemsPerRec;
07948                 (*coord)++;
07949         }
07950         FREE_ONSTACK(coord);
07951         } /* elemsPerRec */
07952 
07953         return status;
07954 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7805 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_float(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. Referenced by THD_load_minc(). 
 07806 {
07807         int status = NC_NOERR;
07808         NC *ncp;
07809         const NC_var *varp;
07810 
07811         status = NC_check_id(ncid, &ncp); 
07812         if(status != NC_NOERR)
07813                 return status;
07814 
07815         if(NC_indef(ncp))
07816                 return NC_EINDEFINE;
07817 
07818         varp = NC_lookupvar(ncp, varid);
07819         if(varp == NULL)
07820                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07821 
07822         if(varp->ndims == 0) /* scalar variable */
07823         {
07824                 const size_t zed = 0;
07825                 return( getNCv_float(ncp, varp, &zed, 1, value) );
07826         }
07827 
07828         if(varp->type == NC_CHAR)
07829                 return NC_ECHAR;
07830 
07831 
07832         if(!IS_RECVAR(varp))
07833         {
07834                 return(getNCv_float(ncp, varp, coord_zero, *varp->dsizes, value));
07835         }
07836         /* else */
07837 
07838         if(varp->ndims == 1
07839                         && ncp->recsize <= varp->len)
07840         {
07841                 /* one dimensional && the only record variable  */
07842                 return(getNCv_float(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07843                         value));
07844         }
07845         /* else */
07846 
07847         {
07848         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07849         size_t elemsPerRec = 1;
07850         const size_t nrecs = NC_get_numrecs(ncp);
07851         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07852         /* TODO: fix dsizes to avoid this nonsense */
07853         if(varp->ndims > 1)
07854                 elemsPerRec = varp->dsizes[1];
07855         while(*coord < nrecs)
07856         {
07857                 const int lstatus = getNCv_float(ncp, varp, coord, elemsPerRec,
07858                                 value);
07859                 if(lstatus != NC_NOERR)
07860                 {
07861                         if(lstatus != NC_ERANGE)
07862                         {
07863                                 status = lstatus;
07864                                 /* fatal for the loop */
07865                                 break;
07866                         }
07867                         /* else NC_ERANGE, not fatal for the loop */
07868                         if(status == NC_NOERR)
07869                                 status = lstatus;
07870                 }
07871                 value += elemsPerRec;
07872                 (*coord)++;
07873         }
07874         FREE_ONSTACK(coord);
07875         } /* elemsPerRec */
07876 
07877         return status;
07878 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7653 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_int(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. 
 07654 {
07655         int status = NC_NOERR;
07656         NC *ncp;
07657         const NC_var *varp;
07658 
07659         status = NC_check_id(ncid, &ncp); 
07660         if(status != NC_NOERR)
07661                 return status;
07662 
07663         if(NC_indef(ncp))
07664                 return NC_EINDEFINE;
07665 
07666         varp = NC_lookupvar(ncp, varid);
07667         if(varp == NULL)
07668                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07669 
07670         if(varp->ndims == 0) /* scalar variable */
07671         {
07672                 const size_t zed = 0;
07673                 return( getNCv_int(ncp, varp, &zed, 1, value) );
07674         }
07675 
07676         if(varp->type == NC_CHAR)
07677                 return NC_ECHAR;
07678 
07679 
07680         if(!IS_RECVAR(varp))
07681         {
07682                 return(getNCv_int(ncp, varp, coord_zero, *varp->dsizes, value));
07683         }
07684         /* else */
07685 
07686         if(varp->ndims == 1
07687                         && ncp->recsize <= varp->len)
07688         {
07689                 /* one dimensional && the only record variable  */
07690                 return(getNCv_int(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07691                         value));
07692         }
07693         /* else */
07694 
07695         {
07696         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07697         size_t elemsPerRec = 1;
07698         const size_t nrecs = NC_get_numrecs(ncp);
07699         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07700         /* TODO: fix dsizes to avoid this nonsense */
07701         if(varp->ndims > 1)
07702                 elemsPerRec = varp->dsizes[1];
07703         while(*coord < nrecs)
07704         {
07705                 const int lstatus = getNCv_int(ncp, varp, coord, elemsPerRec,
07706                                 value);
07707                 if(lstatus != NC_NOERR)
07708                 {
07709                         if(lstatus != NC_ERANGE)
07710                         {
07711                                 status = lstatus;
07712                                 /* fatal for the loop */
07713                                 break;
07714                         }
07715                         /* else NC_ERANGE, not fatal for the loop */
07716                         if(status == NC_NOERR)
07717                                 status = lstatus;
07718                 }
07719                 value += elemsPerRec;
07720                 (*coord)++;
07721         }
07722         FREE_ONSTACK(coord);
07723         } /* elemsPerRec */
07724 
07725         return status;
07726 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7729 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_long(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. 
 07730 {
07731         int status = NC_NOERR;
07732         NC *ncp;
07733         const NC_var *varp;
07734 
07735         status = NC_check_id(ncid, &ncp); 
07736         if(status != NC_NOERR)
07737                 return status;
07738 
07739         if(NC_indef(ncp))
07740                 return NC_EINDEFINE;
07741 
07742         varp = NC_lookupvar(ncp, varid);
07743         if(varp == NULL)
07744                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07745 
07746         if(varp->ndims == 0) /* scalar variable */
07747         {
07748                 const size_t zed = 0;
07749                 return( getNCv_long(ncp, varp, &zed, 1, value) );
07750         }
07751 
07752         if(varp->type == NC_CHAR)
07753                 return NC_ECHAR;
07754 
07755 
07756         if(!IS_RECVAR(varp))
07757         {
07758                 return(getNCv_long(ncp, varp, coord_zero, *varp->dsizes, value));
07759         }
07760         /* else */
07761 
07762         if(varp->ndims == 1
07763                         && ncp->recsize <= varp->len)
07764         {
07765                 /* one dimensional && the only record variable  */
07766                 return(getNCv_long(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07767                         value));
07768         }
07769         /* else */
07770 
07771         {
07772         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07773         size_t elemsPerRec = 1;
07774         const size_t nrecs = NC_get_numrecs(ncp);
07775         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07776         /* TODO: fix dsizes to avoid this nonsense */
07777         if(varp->ndims > 1)
07778                 elemsPerRec = varp->dsizes[1];
07779         while(*coord < nrecs)
07780         {
07781                 const int lstatus = getNCv_long(ncp, varp, coord, elemsPerRec,
07782                                 value);
07783                 if(lstatus != NC_NOERR)
07784                 {
07785                         if(lstatus != NC_ERANGE)
07786                         {
07787                                 status = lstatus;
07788                                 /* fatal for the loop */
07789                                 break;
07790                         }
07791                         /* else NC_ERANGE, not fatal for the loop */
07792                         if(status == NC_NOERR)
07793                                 status = lstatus;
07794                 }
07795                 value += elemsPerRec;
07796                 (*coord)++;
07797         }
07798         FREE_ONSTACK(coord);
07799         } /* elemsPerRec */
07800 
07801         return status;
07802 }
 | 
| 
 | ||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7577 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_short(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. Referenced by THD_load_minc(). 
 07578 {
07579         int status = NC_NOERR;
07580         NC *ncp;
07581         const NC_var *varp;
07582 
07583         status = NC_check_id(ncid, &ncp); 
07584         if(status != NC_NOERR)
07585                 return status;
07586 
07587         if(NC_indef(ncp))
07588                 return NC_EINDEFINE;
07589 
07590         varp = NC_lookupvar(ncp, varid);
07591         if(varp == NULL)
07592                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07593 
07594         if(varp->ndims == 0) /* scalar variable */
07595         {
07596                 const size_t zed = 0;
07597                 return( getNCv_short(ncp, varp, &zed, 1, value) );
07598         }
07599 
07600         if(varp->type == NC_CHAR)
07601                 return NC_ECHAR;
07602 
07603 
07604         if(!IS_RECVAR(varp))
07605         {
07606                 return(getNCv_short(ncp, varp, coord_zero, *varp->dsizes, value));
07607         }
07608         /* else */
07609 
07610         if(varp->ndims == 1
07611                         && ncp->recsize <= varp->len)
07612         {
07613                 /* one dimensional && the only record variable  */
07614                 return(getNCv_short(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07615                         value));
07616         }
07617         /* else */
07618 
07619         {
07620         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07621         size_t elemsPerRec = 1;
07622         const size_t nrecs = NC_get_numrecs(ncp);
07623         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07624         /* TODO: fix dsizes to avoid this nonsense */
07625         if(varp->ndims > 1)
07626                 elemsPerRec = varp->dsizes[1];
07627         while(*coord < nrecs)
07628         {
07629                 const int lstatus = getNCv_short(ncp, varp, coord, elemsPerRec,
07630                                 value);
07631                 if(lstatus != NC_NOERR)
07632                 {
07633                         if(lstatus != NC_ERANGE)
07634                         {
07635                                 status = lstatus;
07636                                 /* fatal for the loop */
07637                                 break;
07638                         }
07639                         /* else NC_ERANGE, not fatal for the loop */
07640                         if(status == NC_NOERR)
07641                                 status = lstatus;
07642                 }
07643                 value += elemsPerRec;
07644                 (*coord)++;
07645         }
07646         FREE_ONSTACK(coord);
07647         } /* elemsPerRec */
07648 
07649         return status;
07650 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7348 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, getNCv_text(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_var::ndims, NC::recsize, and NC_var::type. 
 07349 {
07350         int status = NC_NOERR;
07351         NC *ncp;
07352         const NC_var *varp;
07353 
07354         status = NC_check_id(ncid, &ncp); 
07355         if(status != NC_NOERR)
07356                 return status;
07357 
07358         if(NC_indef(ncp))
07359                 return NC_EINDEFINE;
07360 
07361         varp = NC_lookupvar(ncp, varid);
07362         if(varp == NULL)
07363                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07364 
07365         if(varp->ndims == 0) /* scalar variable */
07366         {
07367                 const size_t zed = 0;
07368                 return( getNCv_text(ncp, varp, &zed, 1, value) );
07369         }
07370 
07371         if(varp->type != NC_CHAR)
07372                 return NC_ECHAR;
07373 
07374 
07375         if(!IS_RECVAR(varp))
07376         {
07377                 return(getNCv_text(ncp, varp, coord_zero, *varp->dsizes, value));
07378         }
07379         /* else */
07380 
07381         if(varp->ndims == 1
07382                         && ncp->recsize <= varp->len)
07383         {
07384                 /* one dimensional && the only record variable  */
07385                 return(getNCv_text(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07386                         value));
07387         }
07388         /* else */
07389 
07390         {
07391         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07392         size_t elemsPerRec = 1;
07393         const size_t nrecs = NC_get_numrecs(ncp);
07394         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07395         /* TODO: fix dsizes to avoid this nonsense */
07396         if(varp->ndims > 1)
07397                 elemsPerRec = varp->dsizes[1];
07398         while(*coord < nrecs)
07399         {
07400                 const int lstatus = getNCv_text(ncp, varp, coord, elemsPerRec,
07401                                 value);
07402                 if(lstatus != NC_NOERR)
07403                 {
07404                         if(lstatus != NC_ERANGE)
07405                         {
07406                                 status = lstatus;
07407                                 /* fatal for the loop */
07408                                 break;
07409                         }
07410                         /* else NC_ERANGE, not fatal for the loop */
07411                         if(status == NC_NOERR)
07412                                 status = lstatus;
07413                 }
07414                 value += elemsPerRec;
07415                 (*coord)++;
07416         }
07417         FREE_ONSTACK(coord);
07418         } /* elemsPerRec */
07419 
07420         return status;
07421 }
 | 
| 
 | ||||||||||||||||
| 
 Referenced by THD_load_minc(). | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 6560 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_double(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_get_vara(), nc_get_varm_double(), and vardata(). 
 06562 {
06563         int status = NC_NOERR;
06564         NC *ncp;
06565         const NC_var *varp;
06566         int ii;
06567         size_t iocount;
06568 
06569         status = NC_check_id(ncid, &ncp); 
06570         if(status != NC_NOERR)
06571                 return status;
06572 
06573         if(NC_indef(ncp))
06574                 return NC_EINDEFINE;
06575 
06576         varp = NC_lookupvar(ncp, varid);
06577         if(varp == NULL)
06578                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06579 
06580         if(varp->type == NC_CHAR)
06581                 return NC_ECHAR;
06582 
06583         status = NCcoordck(ncp, varp, start);
06584         if(status != NC_NOERR)
06585                 return status;
06586         status = NCedgeck(ncp, varp, start, edges);
06587         if(status != NC_NOERR)
06588                 return status;
06589 
06590         if(varp->ndims == 0) /* scalar variable */
06591         {
06592                 return( getNCv_double(ncp, varp, start, 1, value) );
06593         }
06594 
06595         if(IS_RECVAR(varp))
06596         {
06597                 if(*start + *edges > NC_get_numrecs(ncp))
06598                         return NC_EEDGE;
06599                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
06600                 {
06601                         /* one dimensional && the only record variable  */
06602                         return( getNCv_double(ncp, varp, start, *edges, value) );
06603                 }
06604         }
06605 
06606         /*
06607          * find max contiguous
06608          *   and accumulate max count for a single io operation
06609          */
06610         ii = NCiocount(ncp, varp, edges, &iocount);
06611 
06612         if(ii == -1)
06613         {
06614                 return( getNCv_double(ncp, varp, start, iocount, value) );
06615         }
06616 
06617         assert(ii >= 0);
06618 
06619 
06620         { /* inline */
06621         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06622         ALLOC_ONSTACK(upper, size_t, varp->ndims);
06623         const size_t index = ii;
06624 
06625         /* copy in starting indices */
06626         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
06627 
06628         /* set up in maximum indices */
06629         set_upper(upper, start, edges, &upper[varp->ndims]);
06630 
06631         /* ripple counter */
06632         while(*coord < *upper)
06633         {
06634                 const int lstatus = getNCv_double(ncp, varp, coord, iocount,
06635                                 value);
06636                 if(lstatus != NC_NOERR)
06637                 {
06638                         if(lstatus != NC_ERANGE)
06639                         {
06640                                 status = lstatus;
06641                                 /* fatal for the loop */
06642                                 break;
06643                         }
06644                         /* else NC_ERANGE, not fatal for the loop */
06645                         if(status == NC_NOERR)
06646                                 status = lstatus;
06647                 }
06648                 value += iocount;
06649                 odo1(start, upper, coord, &upper[index], &coord[index]);
06650         }
06651 
06652         FREE_ONSTACK(upper);
06653         FREE_ONSTACK(coord);
06654         } /* end inline */
06655 
06656         return status;
06657 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 6460 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_float(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_get_vara(), nc_get_varm_float(), THD_load_minc(), and vardata(). 
 06462 {
06463         int status = NC_NOERR;
06464         NC *ncp;
06465         const NC_var *varp;
06466         int ii;
06467         size_t iocount;
06468 
06469         status = NC_check_id(ncid, &ncp); 
06470         if(status != NC_NOERR)
06471                 return status;
06472 
06473         if(NC_indef(ncp))
06474                 return NC_EINDEFINE;
06475 
06476         varp = NC_lookupvar(ncp, varid);
06477         if(varp == NULL)
06478                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06479 
06480         if(varp->type == NC_CHAR)
06481                 return NC_ECHAR;
06482 
06483         status = NCcoordck(ncp, varp, start);
06484         if(status != NC_NOERR)
06485                 return status;
06486         status = NCedgeck(ncp, varp, start, edges);
06487         if(status != NC_NOERR)
06488                 return status;
06489 
06490         if(varp->ndims == 0) /* scalar variable */
06491         {
06492                 return( getNCv_float(ncp, varp, start, 1, value) );
06493         }
06494 
06495         if(IS_RECVAR(varp))
06496         {
06497                 if(*start + *edges > NC_get_numrecs(ncp))
06498                         return NC_EEDGE;
06499                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
06500                 {
06501                         /* one dimensional && the only record variable  */
06502                         return( getNCv_float(ncp, varp, start, *edges, value) );
06503                 }
06504         }
06505 
06506         /*
06507          * find max contiguous
06508          *   and accumulate max count for a single io operation
06509          */
06510         ii = NCiocount(ncp, varp, edges, &iocount);
06511 
06512         if(ii == -1)
06513         {
06514                 return( getNCv_float(ncp, varp, start, iocount, value) );
06515         }
06516 
06517         assert(ii >= 0);
06518 
06519 
06520         { /* inline */
06521         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06522         ALLOC_ONSTACK(upper, size_t, varp->ndims);
06523         const size_t index = ii;
06524 
06525         /* copy in starting indices */
06526         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
06527 
06528         /* set up in maximum indices */
06529         set_upper(upper, start, edges, &upper[varp->ndims]);
06530 
06531         /* ripple counter */
06532         while(*coord < *upper)
06533         {
06534                 const int lstatus = getNCv_float(ncp, varp, coord, iocount,
06535                                 value);
06536                 if(lstatus != NC_NOERR)
06537                 {
06538                         if(lstatus != NC_ERANGE)
06539                         {
06540                                 status = lstatus;
06541                                 /* fatal for the loop */
06542                                 break;
06543                         }
06544                         /* else NC_ERANGE, not fatal for the loop */
06545                         if(status == NC_NOERR)
06546                                 status = lstatus;
06547                 }
06548                 value += iocount;
06549                 odo1(start, upper, coord, &upper[index], &coord[index]);
06550         }
06551 
06552         FREE_ONSTACK(upper);
06553         FREE_ONSTACK(coord);
06554         } /* end inline */
06555 
06556         return status;
06557 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 6260 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_int(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_get_vara(), nc_get_varm_int(), and vardata(). 
 06262 {
06263         int status = NC_NOERR;
06264         NC *ncp;
06265         const NC_var *varp;
06266         int ii;
06267         size_t iocount;
06268 
06269         status = NC_check_id(ncid, &ncp); 
06270         if(status != NC_NOERR)
06271                 return status;
06272 
06273         if(NC_indef(ncp))
06274                 return NC_EINDEFINE;
06275 
06276         varp = NC_lookupvar(ncp, varid);
06277         if(varp == NULL)
06278                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06279 
06280         if(varp->type == NC_CHAR)
06281                 return NC_ECHAR;
06282 
06283         status = NCcoordck(ncp, varp, start);
06284         if(status != NC_NOERR)
06285                 return status;
06286         status = NCedgeck(ncp, varp, start, edges);
06287         if(status != NC_NOERR)
06288                 return status;
06289 
06290         if(varp->ndims == 0) /* scalar variable */
06291         {
06292                 return( getNCv_int(ncp, varp, start, 1, value) );
06293         }
06294 
06295         if(IS_RECVAR(varp))
06296         {
06297                 if(*start + *edges > NC_get_numrecs(ncp))
06298                         return NC_EEDGE;
06299                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
06300                 {
06301                         /* one dimensional && the only record variable  */
06302                         return( getNCv_int(ncp, varp, start, *edges, value) );
06303                 }
06304         }
06305 
06306         /*
06307          * find max contiguous
06308          *   and accumulate max count for a single io operation
06309          */
06310         ii = NCiocount(ncp, varp, edges, &iocount);
06311 
06312         if(ii == -1)
06313         {
06314                 return( getNCv_int(ncp, varp, start, iocount, value) );
06315         }
06316 
06317         assert(ii >= 0);
06318 
06319 
06320         { /* inline */
06321         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06322         ALLOC_ONSTACK(upper, size_t, varp->ndims);
06323         const size_t index = ii;
06324 
06325         /* copy in starting indices */
06326         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
06327 
06328         /* set up in maximum indices */
06329         set_upper(upper, start, edges, &upper[varp->ndims]);
06330 
06331         /* ripple counter */
06332         while(*coord < *upper)
06333         {
06334                 const int lstatus = getNCv_int(ncp, varp, coord, iocount,
06335                                 value);
06336                 if(lstatus != NC_NOERR)
06337                 {
06338                         if(lstatus != NC_ERANGE)
06339                         {
06340                                 status = lstatus;
06341                                 /* fatal for the loop */
06342                                 break;
06343                         }
06344                         /* else NC_ERANGE, not fatal for the loop */
06345                         if(status == NC_NOERR)
06346                                 status = lstatus;
06347                 }
06348                 value += iocount;
06349                 odo1(start, upper, coord, &upper[index], &coord[index]);
06350         }
06351 
06352         FREE_ONSTACK(upper);
06353         FREE_ONSTACK(coord);
06354         } /* end inline */
06355 
06356         return status;
06357 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 6360 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_long(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_get_vara(), and nc_get_varm_long(). 
 06362 {
06363         int status = NC_NOERR;
06364         NC *ncp;
06365         const NC_var *varp;
06366         int ii;
06367         size_t iocount;
06368 
06369         status = NC_check_id(ncid, &ncp); 
06370         if(status != NC_NOERR)
06371                 return status;
06372 
06373         if(NC_indef(ncp))
06374                 return NC_EINDEFINE;
06375 
06376         varp = NC_lookupvar(ncp, varid);
06377         if(varp == NULL)
06378                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06379 
06380         if(varp->type == NC_CHAR)
06381                 return NC_ECHAR;
06382 
06383         status = NCcoordck(ncp, varp, start);
06384         if(status != NC_NOERR)
06385                 return status;
06386         status = NCedgeck(ncp, varp, start, edges);
06387         if(status != NC_NOERR)
06388                 return status;
06389 
06390         if(varp->ndims == 0) /* scalar variable */
06391         {
06392                 return( getNCv_long(ncp, varp, start, 1, value) );
06393         }
06394 
06395         if(IS_RECVAR(varp))
06396         {
06397                 if(*start + *edges > NC_get_numrecs(ncp))
06398                         return NC_EEDGE;
06399                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
06400                 {
06401                         /* one dimensional && the only record variable  */
06402                         return( getNCv_long(ncp, varp, start, *edges, value) );
06403                 }
06404         }
06405 
06406         /*
06407          * find max contiguous
06408          *   and accumulate max count for a single io operation
06409          */
06410         ii = NCiocount(ncp, varp, edges, &iocount);
06411 
06412         if(ii == -1)
06413         {
06414                 return( getNCv_long(ncp, varp, start, iocount, value) );
06415         }
06416 
06417         assert(ii >= 0);
06418 
06419 
06420         { /* inline */
06421         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06422         ALLOC_ONSTACK(upper, size_t, varp->ndims);
06423         const size_t index = ii;
06424 
06425         /* copy in starting indices */
06426         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
06427 
06428         /* set up in maximum indices */
06429         set_upper(upper, start, edges, &upper[varp->ndims]);
06430 
06431         /* ripple counter */
06432         while(*coord < *upper)
06433         {
06434                 const int lstatus = getNCv_long(ncp, varp, coord, iocount,
06435                                 value);
06436                 if(lstatus != NC_NOERR)
06437                 {
06438                         if(lstatus != NC_ERANGE)
06439                         {
06440                                 status = lstatus;
06441                                 /* fatal for the loop */
06442                                 break;
06443                         }
06444                         /* else NC_ERANGE, not fatal for the loop */
06445                         if(status == NC_NOERR)
06446                                 status = lstatus;
06447                 }
06448                 value += iocount;
06449                 odo1(start, upper, coord, &upper[index], &coord[index]);
06450         }
06451 
06452         FREE_ONSTACK(upper);
06453         FREE_ONSTACK(coord);
06454         } /* end inline */
06455 
06456         return status;
06457 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Referenced by main(), nc_get_vara(), nc_get_varm_schar(), and vardata(). | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 6160 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_short(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_get_vara(), nc_get_varm_short(), THD_load_minc(), and vardata(). 
 06162 {
06163         int status = NC_NOERR;
06164         NC *ncp;
06165         const NC_var *varp;
06166         int ii;
06167         size_t iocount;
06168 
06169         status = NC_check_id(ncid, &ncp); 
06170         if(status != NC_NOERR)
06171                 return status;
06172 
06173         if(NC_indef(ncp))
06174                 return NC_EINDEFINE;
06175 
06176         varp = NC_lookupvar(ncp, varid);
06177         if(varp == NULL)
06178                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06179 
06180         if(varp->type == NC_CHAR)
06181                 return NC_ECHAR;
06182 
06183         status = NCcoordck(ncp, varp, start);
06184         if(status != NC_NOERR)
06185                 return status;
06186         status = NCedgeck(ncp, varp, start, edges);
06187         if(status != NC_NOERR)
06188                 return status;
06189 
06190         if(varp->ndims == 0) /* scalar variable */
06191         {
06192                 return( getNCv_short(ncp, varp, start, 1, value) );
06193         }
06194 
06195         if(IS_RECVAR(varp))
06196         {
06197                 if(*start + *edges > NC_get_numrecs(ncp))
06198                         return NC_EEDGE;
06199                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
06200                 {
06201                         /* one dimensional && the only record variable  */
06202                         return( getNCv_short(ncp, varp, start, *edges, value) );
06203                 }
06204         }
06205 
06206         /*
06207          * find max contiguous
06208          *   and accumulate max count for a single io operation
06209          */
06210         ii = NCiocount(ncp, varp, edges, &iocount);
06211 
06212         if(ii == -1)
06213         {
06214                 return( getNCv_short(ncp, varp, start, iocount, value) );
06215         }
06216 
06217         assert(ii >= 0);
06218 
06219 
06220         { /* inline */
06221         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06222         ALLOC_ONSTACK(upper, size_t, varp->ndims);
06223         const size_t index = ii;
06224 
06225         /* copy in starting indices */
06226         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
06227 
06228         /* set up in maximum indices */
06229         set_upper(upper, start, edges, &upper[varp->ndims]);
06230 
06231         /* ripple counter */
06232         while(*coord < *upper)
06233         {
06234                 const int lstatus = getNCv_short(ncp, varp, coord, iocount,
06235                                 value);
06236                 if(lstatus != NC_NOERR)
06237                 {
06238                         if(lstatus != NC_ERANGE)
06239                         {
06240                                 status = lstatus;
06241                                 /* fatal for the loop */
06242                                 break;
06243                         }
06244                         /* else NC_ERANGE, not fatal for the loop */
06245                         if(status == NC_NOERR)
06246                                 status = lstatus;
06247                 }
06248                 value += iocount;
06249                 odo1(start, upper, coord, &upper[index], &coord[index]);
06250         }
06251 
06252         FREE_ONSTACK(upper);
06253         FREE_ONSTACK(coord);
06254         } /* end inline */
06255 
06256         return status;
06257 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5859 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, getNCv_text(), IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NCcoordck(), NCedgeck(), NCiocount(), NC_var::ndims, odo1(), NC::recsize, set_upper(), and NC_var::type. Referenced by main(), nc_get_vara(), nc_get_varm_text(), and vardata(). 
 05861 {
05862         int status = NC_NOERR;
05863         NC *ncp;
05864         const NC_var *varp;
05865         int ii;
05866         size_t iocount;
05867 
05868         status = NC_check_id(ncid, &ncp); 
05869         if(status != NC_NOERR)
05870                 return status;
05871 
05872         if(NC_indef(ncp))
05873                 return NC_EINDEFINE;
05874 
05875         varp = NC_lookupvar(ncp, varid);
05876         if(varp == NULL)
05877                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05878 
05879         if(varp->type != NC_CHAR)
05880                 return NC_ECHAR;
05881 
05882         status = NCcoordck(ncp, varp, start);
05883         if(status != NC_NOERR)
05884                 return status;
05885         status = NCedgeck(ncp, varp, start, edges);
05886         if(status != NC_NOERR)
05887                 return status;
05888 
05889         if(varp->ndims == 0) /* scalar variable */
05890         {
05891                 return( getNCv_text(ncp, varp, start, 1, value) );
05892         }
05893 
05894         if(IS_RECVAR(varp))
05895         {
05896                 if(*start + *edges > NC_get_numrecs(ncp))
05897                         return NC_EEDGE;
05898                 if(varp->ndims == 1 && ncp->recsize <= varp->len)
05899                 {
05900                         /* one dimensional && the only record variable  */
05901                         return( getNCv_text(ncp, varp, start, *edges, value) );
05902                 }
05903         }
05904 
05905         /*
05906          * find max contiguous
05907          *   and accumulate max count for a single io operation
05908          */
05909         ii = NCiocount(ncp, varp, edges, &iocount);
05910 
05911         if(ii == -1)
05912         {
05913                 return( getNCv_text(ncp, varp, start, iocount, value) );
05914         }
05915 
05916         assert(ii >= 0);
05917 
05918 
05919         { /* inline */
05920         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05921         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05922         const size_t index = ii;
05923 
05924         /* copy in starting indices */
05925         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05926 
05927         /* set up in maximum indices */
05928         set_upper(upper, start, edges, &upper[varp->ndims]);
05929 
05930         /* ripple counter */
05931         while(*coord < *upper)
05932         {
05933                 const int lstatus = getNCv_text(ncp, varp, coord, iocount,
05934                                 value);
05935                 if(lstatus != NC_NOERR)
05936                 {
05937                         if(lstatus != NC_ERANGE)
05938                         {
05939                                 status = lstatus;
05940                                 /* fatal for the loop */
05941                                 break;
05942                         }
05943                         /* else NC_ERANGE, not fatal for the loop */
05944                         if(status == NC_NOERR)
05945                                 status = lstatus;
05946                 }
05947                 value += iocount;
05948                 odo1(start, upper, coord, &upper[index], &coord[index]);
05949         }
05950 
05951         FREE_ONSTACK(upper);
05952         FREE_ONSTACK(coord);
05953         } /* end inline */
05954 
05955         return status;
05956 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Referenced by nc_get_varm_uchar(), and THD_load_minc(). | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 9518 of file putget.c. References calloc, free, getNCv_double(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_double(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_double(). 
 09523 {
09524         int status = ENOERR;
09525         NC *ncp;
09526         NC_var *varp;
09527         int maxidim;    /* maximum dimensional index */
09528 
09529         status = NC_check_id (ncid, &ncp);
09530         if (status != NC_NOERR)
09531                 return status;
09532 
09533         if (NC_indef (ncp))
09534         {
09535                 return NC_EINDEFINE;
09536         }
09537 
09538         varp = NC_lookupvar (ncp, varid);
09539         if (varp == NULL)
09540                 return NC_ENOTVAR;
09541 
09542         if(varp->type == NC_CHAR)
09543                 return NC_ECHAR;
09544 
09545         maxidim = (int) varp->ndims - 1;
09546 
09547         if (maxidim < 0)
09548         {
09549                 /*
09550                  * The variable is a scalar; consequently,
09551                  * there s only one thing to get and only one place to put it.
09552                  * (Why was I called?)
09553                  */
09554                 return getNCv_double (ncp, varp, start, 1, value);
09555         }
09556         
09557         /*
09558          * else
09559          * The variable is an array.
09560          */
09561         {
09562                 int idim;
09563                 size_t *mystart = NULL;
09564                 size_t *myedges;
09565                 size_t *iocount;        /* count vector */
09566                 size_t *stop;   /* stop indexes */
09567                 size_t *length; /* edge lengths in bytes */
09568                 ptrdiff_t *mystride;
09569                 ptrdiff_t *mymap;
09570 
09571                 /*
09572                  * Verify stride argument.
09573                  */
09574                 for (idim = 0; idim <= maxidim; ++idim)
09575                 {
09576                         if (stride != NULL
09577                                 && (stride[idim] == 0
09578                 /* cast needed for braindead systems with signed size_t */
09579                                 || (unsigned long) stride[idim] >= X_INT_MAX))
09580                         {
09581                                 return NC_ESTRIDE;
09582                         }
09583                 }
09584 
09585                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
09586                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
09587                 if(mystart == NULL)
09588                         return NC_ENOMEM;
09589                 myedges = mystart + varp->ndims;
09590                 iocount = myedges + varp->ndims;
09591                 stop = iocount + varp->ndims;
09592                 length = stop + varp->ndims;
09593                 mystride = (ptrdiff_t *)(length + varp->ndims);
09594                 mymap = mystride + varp->ndims;
09595 
09596                 /*
09597                  * Initialize I/O parameters.
09598                  */
09599                 for (idim = maxidim; idim >= 0; --idim)
09600                 {
09601                         mystart[idim] = start != NULL
09602                                 ? start[idim]
09603                                 : 0;
09604 
09605                         if (edges[idim] == 0)
09606                         {
09607                                 status = NC_NOERR;      /* read/write no data */
09608                                 goto done;
09609                         }
09610 
09611                         myedges[idim] = edges != NULL
09612                                 ? edges[idim]
09613                                 : idim == 0 && IS_RECVAR (varp)
09614                                 ? NC_get_numrecs(ncp) - mystart[idim]
09615                                 : varp->shape[idim] - mystart[idim];
09616                         mystride[idim] = stride != NULL
09617                                 ? stride[idim]
09618                                 : 1;
09619                         mymap[idim] = map != NULL
09620                                 ? map[idim]
09621                                 : idim == maxidim
09622                                 ? 1
09623                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
09624 
09625                         iocount[idim] = 1;
09626                         length[idim] = mymap[idim] * myedges[idim];
09627                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
09628                 }
09629 
09630                 /*
09631                  * Check start, edges
09632                  */
09633                 for (idim = maxidim; idim >= 0; --idim)
09634                 {
09635                         size_t dimlen = 
09636                                 idim == 0 && IS_RECVAR (varp)
09637                                         ? NC_get_numrecs(ncp)
09638                                           : varp->shape[idim];
09639                         if (mystart[idim] >= dimlen)
09640                         {
09641                                 status = NC_EINVALCOORDS;
09642                                 goto done;
09643                         }
09644 
09645                         if (mystart[idim] + myedges[idim] > dimlen)
09646                         {
09647                                 status = NC_EEDGE;
09648                                 goto done;
09649                         }
09650 
09651                 }
09652                 /*
09653                  * As an optimization, adjust I/O parameters when the fastest 
09654                  * dimension has unity stride both externally and internally.
09655                  * In this case, the user could have called a simpler routine
09656                  * (i.e. ncvarnc_get_vara_double()
09657                  */
09658                 if (mystride[maxidim] == 1
09659                         && mymap[maxidim] == 1)
09660                 {
09661                         iocount[maxidim] = myedges[maxidim];
09662                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
09663                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
09664                 }
09665 
09666                 /*
09667                  * Perform I/O.  Exit when done.
09668                  */
09669                 for (;;)
09670                 {
09671                         /* TODO: */
09672                         int lstatus = nc_get_vara_double (ncid, varid, mystart, iocount,
09673                                                 value);
09674                         if (lstatus != NC_NOERR 
09675                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
09676                                 status = lstatus;
09677 
09678                         /*
09679                          * The following code permutes through the variable s
09680                          * external start-index space and it s internal address
09681                          * space.  At the UPC, this algorithm is commonly
09682                          * called "odometer code".
09683                          */
09684                         idim = maxidim;
09685                 carry:
09686                         value += mymap[idim];
09687                         mystart[idim] += mystride[idim];
09688                         if (mystart[idim] == stop[idim])
09689                         {
09690                                 mystart[idim] = start[idim];
09691                                 value -= length[idim];
09692                                 if (--idim < 0)
09693                                         break; /* normal return */
09694                                 goto carry;
09695                         }
09696                 } /* I/O loop */
09697         done:
09698                 free(mystart);
09699         } /* variable is array */
09700         return status;
09701 
09702 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 9331 of file putget.c. References calloc, free, getNCv_float(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_float(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_float(). 
 09336 {
09337         int status = ENOERR;
09338         NC *ncp;
09339         NC_var *varp;
09340         int maxidim;    /* maximum dimensional index */
09341 
09342         status = NC_check_id (ncid, &ncp);
09343         if (status != NC_NOERR)
09344                 return status;
09345 
09346         if (NC_indef (ncp))
09347         {
09348                 return NC_EINDEFINE;
09349         }
09350 
09351         varp = NC_lookupvar (ncp, varid);
09352         if (varp == NULL)
09353                 return NC_ENOTVAR;
09354 
09355         if(varp->type == NC_CHAR)
09356                 return NC_ECHAR;
09357 
09358         maxidim = (int) varp->ndims - 1;
09359 
09360         if (maxidim < 0)
09361         {
09362                 /*
09363                  * The variable is a scalar; consequently,
09364                  * there s only one thing to get and only one place to put it.
09365                  * (Why was I called?)
09366                  */
09367                 return getNCv_float (ncp, varp, start, 1, value);
09368         }
09369         
09370         /*
09371          * else
09372          * The variable is an array.
09373          */
09374         {
09375                 int idim;
09376                 size_t *mystart = NULL;
09377                 size_t *myedges;
09378                 size_t *iocount;        /* count vector */
09379                 size_t *stop;   /* stop indexes */
09380                 size_t *length; /* edge lengths in bytes */
09381                 ptrdiff_t *mystride;
09382                 ptrdiff_t *mymap;
09383 
09384                 /*
09385                  * Verify stride argument.
09386                  */
09387                 for (idim = 0; idim <= maxidim; ++idim)
09388                 {
09389                         if (stride != NULL
09390                                 && (stride[idim] == 0
09391                 /* cast needed for braindead systems with signed size_t */
09392                                 || (unsigned long) stride[idim] >= X_INT_MAX))
09393                         {
09394                                 return NC_ESTRIDE;
09395                         }
09396                 }
09397 
09398                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
09399                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
09400                 if(mystart == NULL)
09401                         return NC_ENOMEM;
09402                 myedges = mystart + varp->ndims;
09403                 iocount = myedges + varp->ndims;
09404                 stop = iocount + varp->ndims;
09405                 length = stop + varp->ndims;
09406                 mystride = (ptrdiff_t *)(length + varp->ndims);
09407                 mymap = mystride + varp->ndims;
09408 
09409                 /*
09410                  * Initialize I/O parameters.
09411                  */
09412                 for (idim = maxidim; idim >= 0; --idim)
09413                 {
09414                         mystart[idim] = start != NULL
09415                                 ? start[idim]
09416                                 : 0;
09417 
09418                         if (edges[idim] == 0)
09419                         {
09420                                 status = NC_NOERR;      /* read/write no data */
09421                                 goto done;
09422                         }
09423 
09424                         myedges[idim] = edges != NULL
09425                                 ? edges[idim]
09426                                 : idim == 0 && IS_RECVAR (varp)
09427                                 ? NC_get_numrecs(ncp) - mystart[idim]
09428                                 : varp->shape[idim] - mystart[idim];
09429                         mystride[idim] = stride != NULL
09430                                 ? stride[idim]
09431                                 : 1;
09432                         mymap[idim] = map != NULL
09433                                 ? map[idim]
09434                                 : idim == maxidim
09435                                 ? 1
09436                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
09437 
09438                         iocount[idim] = 1;
09439                         length[idim] = mymap[idim] * myedges[idim];
09440                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
09441                 }
09442 
09443                 /*
09444                  * Check start, edges
09445                  */
09446                 for (idim = maxidim; idim >= 0; --idim)
09447                 {
09448                         size_t dimlen = 
09449                                 idim == 0 && IS_RECVAR (varp)
09450                                         ? NC_get_numrecs(ncp)
09451                                           : varp->shape[idim];
09452                         if (mystart[idim] >= dimlen)
09453                         {
09454                                 status = NC_EINVALCOORDS;
09455                                 goto done;
09456                         }
09457 
09458                         if (mystart[idim] + myedges[idim] > dimlen)
09459                         {
09460                                 status = NC_EEDGE;
09461                                 goto done;
09462                         }
09463 
09464                 }
09465                 /*
09466                  * As an optimization, adjust I/O parameters when the fastest 
09467                  * dimension has unity stride both externally and internally.
09468                  * In this case, the user could have called a simpler routine
09469                  * (i.e. ncvarnc_get_vara_float()
09470                  */
09471                 if (mystride[maxidim] == 1
09472                         && mymap[maxidim] == 1)
09473                 {
09474                         iocount[maxidim] = myedges[maxidim];
09475                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
09476                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
09477                 }
09478 
09479                 /*
09480                  * Perform I/O.  Exit when done.
09481                  */
09482                 for (;;)
09483                 {
09484                         /* TODO: */
09485                         int lstatus = nc_get_vara_float (ncid, varid, mystart, iocount,
09486                                                 value);
09487                         if (lstatus != NC_NOERR 
09488                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
09489                                 status = lstatus;
09490 
09491                         /*
09492                          * The following code permutes through the variable s
09493                          * external start-index space and it s internal address
09494                          * space.  At the UPC, this algorithm is commonly
09495                          * called "odometer code".
09496                          */
09497                         idim = maxidim;
09498                 carry:
09499                         value += mymap[idim];
09500                         mystart[idim] += mystride[idim];
09501                         if (mystart[idim] == stop[idim])
09502                         {
09503                                 mystart[idim] = start[idim];
09504                                 value -= length[idim];
09505                                 if (--idim < 0)
09506                                         break; /* normal return */
09507                                 goto carry;
09508                         }
09509                 } /* I/O loop */
09510         done:
09511                 free(mystart);
09512         } /* variable is array */
09513         return status;
09514 
09515 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 8957 of file putget.c. References calloc, free, getNCv_int(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_int(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_int(). 
 08962 {
08963         int status = ENOERR;
08964         NC *ncp;
08965         NC_var *varp;
08966         int maxidim;    /* maximum dimensional index */
08967 
08968         status = NC_check_id (ncid, &ncp);
08969         if (status != NC_NOERR)
08970                 return status;
08971 
08972         if (NC_indef (ncp))
08973         {
08974                 return NC_EINDEFINE;
08975         }
08976 
08977         varp = NC_lookupvar (ncp, varid);
08978         if (varp == NULL)
08979                 return NC_ENOTVAR;
08980 
08981         if(varp->type == NC_CHAR)
08982                 return NC_ECHAR;
08983 
08984         maxidim = (int) varp->ndims - 1;
08985 
08986         if (maxidim < 0)
08987         {
08988                 /*
08989                  * The variable is a scalar; consequently,
08990                  * there s only one thing to get and only one place to put it.
08991                  * (Why was I called?)
08992                  */
08993                 return getNCv_int (ncp, varp, start, 1, value);
08994         }
08995         
08996         /*
08997          * else
08998          * The variable is an array.
08999          */
09000         {
09001                 int idim;
09002                 size_t *mystart = NULL;
09003                 size_t *myedges;
09004                 size_t *iocount;        /* count vector */
09005                 size_t *stop;   /* stop indexes */
09006                 size_t *length; /* edge lengths in bytes */
09007                 ptrdiff_t *mystride;
09008                 ptrdiff_t *mymap;
09009 
09010                 /*
09011                  * Verify stride argument.
09012                  */
09013                 for (idim = 0; idim <= maxidim; ++idim)
09014                 {
09015                         if (stride != NULL
09016                                 && (stride[idim] == 0
09017                 /* cast needed for braindead systems with signed size_t */
09018                                 || (unsigned long) stride[idim] >= X_INT_MAX))
09019                         {
09020                                 return NC_ESTRIDE;
09021                         }
09022                 }
09023 
09024                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
09025                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
09026                 if(mystart == NULL)
09027                         return NC_ENOMEM;
09028                 myedges = mystart + varp->ndims;
09029                 iocount = myedges + varp->ndims;
09030                 stop = iocount + varp->ndims;
09031                 length = stop + varp->ndims;
09032                 mystride = (ptrdiff_t *)(length + varp->ndims);
09033                 mymap = mystride + varp->ndims;
09034 
09035                 /*
09036                  * Initialize I/O parameters.
09037                  */
09038                 for (idim = maxidim; idim >= 0; --idim)
09039                 {
09040                         mystart[idim] = start != NULL
09041                                 ? start[idim]
09042                                 : 0;
09043 
09044                         if (edges[idim] == 0)
09045                         {
09046                                 status = NC_NOERR;      /* read/write no data */
09047                                 goto done;
09048                         }
09049 
09050                         myedges[idim] = edges != NULL
09051                                 ? edges[idim]
09052                                 : idim == 0 && IS_RECVAR (varp)
09053                                 ? NC_get_numrecs(ncp) - mystart[idim]
09054                                 : varp->shape[idim] - mystart[idim];
09055                         mystride[idim] = stride != NULL
09056                                 ? stride[idim]
09057                                 : 1;
09058                         mymap[idim] = map != NULL
09059                                 ? map[idim]
09060                                 : idim == maxidim
09061                                 ? 1
09062                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
09063 
09064                         iocount[idim] = 1;
09065                         length[idim] = mymap[idim] * myedges[idim];
09066                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
09067                 }
09068 
09069                 /*
09070                  * Check start, edges
09071                  */
09072                 for (idim = maxidim; idim >= 0; --idim)
09073                 {
09074                         size_t dimlen = 
09075                                 idim == 0 && IS_RECVAR (varp)
09076                                         ? NC_get_numrecs(ncp)
09077                                           : varp->shape[idim];
09078                         if (mystart[idim] >= dimlen)
09079                         {
09080                                 status = NC_EINVALCOORDS;
09081                                 goto done;
09082                         }
09083 
09084                         if (mystart[idim] + myedges[idim] > dimlen)
09085                         {
09086                                 status = NC_EEDGE;
09087                                 goto done;
09088                         }
09089 
09090                 }
09091                 /*
09092                  * As an optimization, adjust I/O parameters when the fastest 
09093                  * dimension has unity stride both externally and internally.
09094                  * In this case, the user could have called a simpler routine
09095                  * (i.e. ncvarnc_get_vara_int()
09096                  */
09097                 if (mystride[maxidim] == 1
09098                         && mymap[maxidim] == 1)
09099                 {
09100                         iocount[maxidim] = myedges[maxidim];
09101                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
09102                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
09103                 }
09104 
09105                 /*
09106                  * Perform I/O.  Exit when done.
09107                  */
09108                 for (;;)
09109                 {
09110                         /* TODO: */
09111                         int lstatus = nc_get_vara_int (ncid, varid, mystart, iocount,
09112                                                 value);
09113                         if (lstatus != NC_NOERR 
09114                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
09115                                 status = lstatus;
09116 
09117                         /*
09118                          * The following code permutes through the variable s
09119                          * external start-index space and it s internal address
09120                          * space.  At the UPC, this algorithm is commonly
09121                          * called "odometer code".
09122                          */
09123                         idim = maxidim;
09124                 carry:
09125                         value += mymap[idim];
09126                         mystart[idim] += mystride[idim];
09127                         if (mystart[idim] == stop[idim])
09128                         {
09129                                 mystart[idim] = start[idim];
09130                                 value -= length[idim];
09131                                 if (--idim < 0)
09132                                         break; /* normal return */
09133                                 goto carry;
09134                         }
09135                 } /* I/O loop */
09136         done:
09137                 free(mystart);
09138         } /* variable is array */
09139         return status;
09140 
09141 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 9144 of file putget.c. References calloc, free, getNCv_long(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_long(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_long(). 
 09149 {
09150         int status = ENOERR;
09151         NC *ncp;
09152         NC_var *varp;
09153         int maxidim;    /* maximum dimensional index */
09154 
09155         status = NC_check_id (ncid, &ncp);
09156         if (status != NC_NOERR)
09157                 return status;
09158 
09159         if (NC_indef (ncp))
09160         {
09161                 return NC_EINDEFINE;
09162         }
09163 
09164         varp = NC_lookupvar (ncp, varid);
09165         if (varp == NULL)
09166                 return NC_ENOTVAR;
09167 
09168         if(varp->type == NC_CHAR)
09169                 return NC_ECHAR;
09170 
09171         maxidim = (int) varp->ndims - 1;
09172 
09173         if (maxidim < 0)
09174         {
09175                 /*
09176                  * The variable is a scalar; consequently,
09177                  * there s only one thing to get and only one place to put it.
09178                  * (Why was I called?)
09179                  */
09180                 return getNCv_long (ncp, varp, start, 1, value);
09181         }
09182         
09183         /*
09184          * else
09185          * The variable is an array.
09186          */
09187         {
09188                 int idim;
09189                 size_t *mystart = NULL;
09190                 size_t *myedges;
09191                 size_t *iocount;        /* count vector */
09192                 size_t *stop;   /* stop indexes */
09193                 size_t *length; /* edge lengths in bytes */
09194                 ptrdiff_t *mystride;
09195                 ptrdiff_t *mymap;
09196 
09197                 /*
09198                  * Verify stride argument.
09199                  */
09200                 for (idim = 0; idim <= maxidim; ++idim)
09201                 {
09202                         if (stride != NULL
09203                                 && (stride[idim] == 0
09204                 /* cast needed for braindead systems with signed size_t */
09205                                 || (unsigned long) stride[idim] >= X_INT_MAX))
09206                         {
09207                                 return NC_ESTRIDE;
09208                         }
09209                 }
09210 
09211                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
09212                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
09213                 if(mystart == NULL)
09214                         return NC_ENOMEM;
09215                 myedges = mystart + varp->ndims;
09216                 iocount = myedges + varp->ndims;
09217                 stop = iocount + varp->ndims;
09218                 length = stop + varp->ndims;
09219                 mystride = (ptrdiff_t *)(length + varp->ndims);
09220                 mymap = mystride + varp->ndims;
09221 
09222                 /*
09223                  * Initialize I/O parameters.
09224                  */
09225                 for (idim = maxidim; idim >= 0; --idim)
09226                 {
09227                         mystart[idim] = start != NULL
09228                                 ? start[idim]
09229                                 : 0;
09230 
09231                         if (edges[idim] == 0)
09232                         {
09233                                 status = NC_NOERR;      /* read/write no data */
09234                                 goto done;
09235                         }
09236 
09237                         myedges[idim] = edges != NULL
09238                                 ? edges[idim]
09239                                 : idim == 0 && IS_RECVAR (varp)
09240                                 ? NC_get_numrecs(ncp) - mystart[idim]
09241                                 : varp->shape[idim] - mystart[idim];
09242                         mystride[idim] = stride != NULL
09243                                 ? stride[idim]
09244                                 : 1;
09245                         mymap[idim] = map != NULL
09246                                 ? map[idim]
09247                                 : idim == maxidim
09248                                 ? 1
09249                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
09250 
09251                         iocount[idim] = 1;
09252                         length[idim] = mymap[idim] * myedges[idim];
09253                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
09254                 }
09255 
09256                 /*
09257                  * Check start, edges
09258                  */
09259                 for (idim = maxidim; idim >= 0; --idim)
09260                 {
09261                         size_t dimlen = 
09262                                 idim == 0 && IS_RECVAR (varp)
09263                                         ? NC_get_numrecs(ncp)
09264                                           : varp->shape[idim];
09265                         if (mystart[idim] >= dimlen)
09266                         {
09267                                 status = NC_EINVALCOORDS;
09268                                 goto done;
09269                         }
09270 
09271                         if (mystart[idim] + myedges[idim] > dimlen)
09272                         {
09273                                 status = NC_EEDGE;
09274                                 goto done;
09275                         }
09276 
09277                 }
09278                 /*
09279                  * As an optimization, adjust I/O parameters when the fastest 
09280                  * dimension has unity stride both externally and internally.
09281                  * In this case, the user could have called a simpler routine
09282                  * (i.e. ncvarnc_get_vara_long()
09283                  */
09284                 if (mystride[maxidim] == 1
09285                         && mymap[maxidim] == 1)
09286                 {
09287                         iocount[maxidim] = myedges[maxidim];
09288                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
09289                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
09290                 }
09291 
09292                 /*
09293                  * Perform I/O.  Exit when done.
09294                  */
09295                 for (;;)
09296                 {
09297                         /* TODO: */
09298                         int lstatus = nc_get_vara_long (ncid, varid, mystart, iocount,
09299                                                 value);
09300                         if (lstatus != NC_NOERR 
09301                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
09302                                 status = lstatus;
09303 
09304                         /*
09305                          * The following code permutes through the variable s
09306                          * external start-index space and it s internal address
09307                          * space.  At the UPC, this algorithm is commonly
09308                          * called "odometer code".
09309                          */
09310                         idim = maxidim;
09311                 carry:
09312                         value += mymap[idim];
09313                         mystart[idim] += mystride[idim];
09314                         if (mystart[idim] == stop[idim])
09315                         {
09316                                 mystart[idim] = start[idim];
09317                                 value -= length[idim];
09318                                 if (--idim < 0)
09319                                         break; /* normal return */
09320                                 goto carry;
09321                         }
09322                 } /* I/O loop */
09323         done:
09324                 free(mystart);
09325         } /* variable is array */
09326         return status;
09327 
09328 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Referenced by nc_get_varm(), and nc_get_vars_schar(). | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 8770 of file putget.c. References calloc, free, getNCv_short(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_short(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_short(). 
 08775 {
08776         int status = ENOERR;
08777         NC *ncp;
08778         NC_var *varp;
08779         int maxidim;    /* maximum dimensional index */
08780 
08781         status = NC_check_id (ncid, &ncp);
08782         if (status != NC_NOERR)
08783                 return status;
08784 
08785         if (NC_indef (ncp))
08786         {
08787                 return NC_EINDEFINE;
08788         }
08789 
08790         varp = NC_lookupvar (ncp, varid);
08791         if (varp == NULL)
08792                 return NC_ENOTVAR;
08793 
08794         if(varp->type == NC_CHAR)
08795                 return NC_ECHAR;
08796 
08797         maxidim = (int) varp->ndims - 1;
08798 
08799         if (maxidim < 0)
08800         {
08801                 /*
08802                  * The variable is a scalar; consequently,
08803                  * there s only one thing to get and only one place to put it.
08804                  * (Why was I called?)
08805                  */
08806                 return getNCv_short (ncp, varp, start, 1, value);
08807         }
08808         
08809         /*
08810          * else
08811          * The variable is an array.
08812          */
08813         {
08814                 int idim;
08815                 size_t *mystart = NULL;
08816                 size_t *myedges;
08817                 size_t *iocount;        /* count vector */
08818                 size_t *stop;   /* stop indexes */
08819                 size_t *length; /* edge lengths in bytes */
08820                 ptrdiff_t *mystride;
08821                 ptrdiff_t *mymap;
08822 
08823                 /*
08824                  * Verify stride argument.
08825                  */
08826                 for (idim = 0; idim <= maxidim; ++idim)
08827                 {
08828                         if (stride != NULL
08829                                 && (stride[idim] == 0
08830                 /* cast needed for braindead systems with signed size_t */
08831                                 || (unsigned long) stride[idim] >= X_INT_MAX))
08832                         {
08833                                 return NC_ESTRIDE;
08834                         }
08835                 }
08836 
08837                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
08838                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
08839                 if(mystart == NULL)
08840                         return NC_ENOMEM;
08841                 myedges = mystart + varp->ndims;
08842                 iocount = myedges + varp->ndims;
08843                 stop = iocount + varp->ndims;
08844                 length = stop + varp->ndims;
08845                 mystride = (ptrdiff_t *)(length + varp->ndims);
08846                 mymap = mystride + varp->ndims;
08847 
08848                 /*
08849                  * Initialize I/O parameters.
08850                  */
08851                 for (idim = maxidim; idim >= 0; --idim)
08852                 {
08853                         mystart[idim] = start != NULL
08854                                 ? start[idim]
08855                                 : 0;
08856 
08857                         if (edges[idim] == 0)
08858                         {
08859                                 status = NC_NOERR;      /* read/write no data */
08860                                 goto done;
08861                         }
08862 
08863                         myedges[idim] = edges != NULL
08864                                 ? edges[idim]
08865                                 : idim == 0 && IS_RECVAR (varp)
08866                                 ? NC_get_numrecs(ncp) - mystart[idim]
08867                                 : varp->shape[idim] - mystart[idim];
08868                         mystride[idim] = stride != NULL
08869                                 ? stride[idim]
08870                                 : 1;
08871                         mymap[idim] = map != NULL
08872                                 ? map[idim]
08873                                 : idim == maxidim
08874                                 ? 1
08875                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
08876 
08877                         iocount[idim] = 1;
08878                         length[idim] = mymap[idim] * myedges[idim];
08879                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
08880                 }
08881 
08882                 /*
08883                  * Check start, edges
08884                  */
08885                 for (idim = maxidim; idim >= 0; --idim)
08886                 {
08887                         size_t dimlen = 
08888                                 idim == 0 && IS_RECVAR (varp)
08889                                         ? NC_get_numrecs(ncp)
08890                                           : varp->shape[idim];
08891                         if (mystart[idim] >= dimlen)
08892                         {
08893                                 status = NC_EINVALCOORDS;
08894                                 goto done;
08895                         }
08896 
08897                         if (mystart[idim] + myedges[idim] > dimlen)
08898                         {
08899                                 status = NC_EEDGE;
08900                                 goto done;
08901                         }
08902 
08903                 }
08904                 /*
08905                  * As an optimization, adjust I/O parameters when the fastest 
08906                  * dimension has unity stride both externally and internally.
08907                  * In this case, the user could have called a simpler routine
08908                  * (i.e. ncvarnc_get_vara_short()
08909                  */
08910                 if (mystride[maxidim] == 1
08911                         && mymap[maxidim] == 1)
08912                 {
08913                         iocount[maxidim] = myedges[maxidim];
08914                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
08915                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
08916                 }
08917 
08918                 /*
08919                  * Perform I/O.  Exit when done.
08920                  */
08921                 for (;;)
08922                 {
08923                         /* TODO: */
08924                         int lstatus = nc_get_vara_short (ncid, varid, mystart, iocount,
08925                                                 value);
08926                         if (lstatus != NC_NOERR 
08927                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
08928                                 status = lstatus;
08929 
08930                         /*
08931                          * The following code permutes through the variable s
08932                          * external start-index space and it s internal address
08933                          * space.  At the UPC, this algorithm is commonly
08934                          * called "odometer code".
08935                          */
08936                         idim = maxidim;
08937                 carry:
08938                         value += mymap[idim];
08939                         mystart[idim] += mystride[idim];
08940                         if (mystart[idim] == stop[idim])
08941                         {
08942                                 mystart[idim] = start[idim];
08943                                 value -= length[idim];
08944                                 if (--idim < 0)
08945                                         break; /* normal return */
08946                                 goto carry;
08947                         }
08948                 } /* I/O loop */
08949         done:
08950                 free(mystart);
08951         } /* variable is array */
08952         return status;
08953 
08954 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 8208 of file putget.c. References calloc, free, getNCv_text(), IS_RECVAR, NC_check_id(), NC_get_numrecs, nc_get_vara_text(), NC_indef, NC_lookupvar(), NC_var::ndims, NC_var::shape, stride, and NC_var::type. Referenced by nc_get_varm(), and nc_get_vars_text(). 
 08213 {
08214         int status = ENOERR;
08215         NC *ncp;
08216         NC_var *varp;
08217         int maxidim;    /* maximum dimensional index */
08218 
08219         status = NC_check_id (ncid, &ncp);
08220         if (status != NC_NOERR)
08221                 return status;
08222 
08223         if (NC_indef (ncp))
08224         {
08225                 return NC_EINDEFINE;
08226         }
08227 
08228         varp = NC_lookupvar (ncp, varid);
08229         if (varp == NULL)
08230                 return NC_ENOTVAR;
08231 
08232         if(varp->type != NC_CHAR)
08233                 return NC_ECHAR;
08234 
08235         maxidim = (int) varp->ndims - 1;
08236 
08237         if (maxidim < 0)
08238         {
08239                 /*
08240                  * The variable is a scalar; consequently,
08241                  * there s only one thing to get and only one place to put it.
08242                  * (Why was I called?)
08243                  */
08244                 return getNCv_text (ncp, varp, start, 1, value);
08245         }
08246         
08247         /*
08248          * else
08249          * The variable is an array.
08250          */
08251         {
08252                 int idim;
08253                 size_t *mystart = NULL;
08254                 size_t *myedges;
08255                 size_t *iocount;        /* count vector */
08256                 size_t *stop;   /* stop indexes */
08257                 size_t *length; /* edge lengths in bytes */
08258                 ptrdiff_t *mystride;
08259                 ptrdiff_t *mymap;
08260 
08261                 /*
08262                  * Verify stride argument.
08263                  */
08264                 for (idim = 0; idim <= maxidim; ++idim)
08265                 {
08266                         if (stride != NULL
08267                                 && (stride[idim] == 0
08268                 /* cast needed for braindead systems with signed size_t */
08269                                 || (unsigned long) stride[idim] >= X_INT_MAX))
08270                         {
08271                                 return NC_ESTRIDE;
08272                         }
08273                 }
08274 
08275                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
08276                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
08277                 if(mystart == NULL)
08278                         return NC_ENOMEM;
08279                 myedges = mystart + varp->ndims;
08280                 iocount = myedges + varp->ndims;
08281                 stop = iocount + varp->ndims;
08282                 length = stop + varp->ndims;
08283                 mystride = (ptrdiff_t *)(length + varp->ndims);
08284                 mymap = mystride + varp->ndims;
08285 
08286                 /*
08287                  * Initialize I/O parameters.
08288                  */
08289                 for (idim = maxidim; idim >= 0; --idim)
08290                 {
08291                         mystart[idim] = start != NULL
08292                                 ? start[idim]
08293                                 : 0;
08294 
08295                         if (edges[idim] == 0)
08296                         {
08297                                 status = NC_NOERR;      /* read/write no data */
08298                                 goto done;
08299                         }
08300 
08301                         myedges[idim] = edges != NULL
08302                                 ? edges[idim]
08303                                 : idim == 0 && IS_RECVAR (varp)
08304                                 ? NC_get_numrecs(ncp) - mystart[idim]
08305                                 : varp->shape[idim] - mystart[idim];
08306                         mystride[idim] = stride != NULL
08307                                 ? stride[idim]
08308                                 : 1;
08309                         mymap[idim] = map != NULL
08310                                 ? map[idim]
08311                                 : idim == maxidim
08312                                 ? 1
08313                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
08314 
08315                         iocount[idim] = 1;
08316                         length[idim] = mymap[idim] * myedges[idim];
08317                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
08318                 }
08319 
08320                 /*
08321                  * Check start, edges
08322                  */
08323                 for (idim = maxidim; idim >= 0; --idim)
08324                 {
08325                         size_t dimlen = 
08326                                 idim == 0 && IS_RECVAR (varp)
08327                                         ? NC_get_numrecs(ncp)
08328                                           : varp->shape[idim];
08329                         if (mystart[idim] >= dimlen)
08330                         {
08331                                 status = NC_EINVALCOORDS;
08332                                 goto done;
08333                         }
08334 
08335                         if (mystart[idim] + myedges[idim] > dimlen)
08336                         {
08337                                 status = NC_EEDGE;
08338                                 goto done;
08339                         }
08340 
08341                 }
08342                 /*
08343                  * As an optimization, adjust I/O parameters when the fastest 
08344                  * dimension has unity stride both externally and internally.
08345                  * In this case, the user could have called a simpler routine
08346                  * (i.e. ncvarnc_get_vara_text()
08347                  */
08348                 if (mystride[maxidim] == 1
08349                         && mymap[maxidim] == 1)
08350                 {
08351                         iocount[maxidim] = myedges[maxidim];
08352                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
08353                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
08354                 }
08355 
08356                 /*
08357                  * Perform I/O.  Exit when done.
08358                  */
08359                 for (;;)
08360                 {
08361                         /* TODO: */
08362                         int lstatus = nc_get_vara_text (ncid, varid, mystart, iocount,
08363                                                 value);
08364                         if (lstatus != NC_NOERR 
08365                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
08366                                 status = lstatus;
08367 
08368                         /*
08369                          * The following code permutes through the variable s
08370                          * external start-index space and it s internal address
08371                          * space.  At the UPC, this algorithm is commonly
08372                          * called "odometer code".
08373                          */
08374                         idim = maxidim;
08375                 carry:
08376                         value += mymap[idim];
08377                         mystart[idim] += mystride[idim];
08378                         if (mystart[idim] == stop[idim])
08379                         {
08380                                 mystart[idim] = start[idim];
08381                                 value -= length[idim];
08382                                 if (--idim < 0)
08383                                         break; /* normal return */
08384                                 goto carry;
08385                         }
08386                 } /* I/O loop */
08387         done:
08388                 free(mystart);
08389         } /* variable is array */
08390         return status;
08391 
08392 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Referenced by nc_get_vars_uchar(). | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8055 of file putget.c. References nc_get_varm_double(), and stride. 
 08062 {
08063         return nc_get_varm_double (ncid, varid, start, edges,
08064                          stride, 0, value);
08065 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8042 of file putget.c. References nc_get_varm_float(), and stride. 
 08049 {
08050         return nc_get_varm_float (ncid, varid, start, edges,
08051                          stride, 0, value);
08052 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8016 of file putget.c. References nc_get_varm_int(), and stride. 
 08023 {
08024         return nc_get_varm_int (ncid, varid, start, edges,
08025                          stride, 0, value);
08026 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8029 of file putget.c. References nc_get_varm_long(), and stride. 
 08036 {
08037         return nc_get_varm_long (ncid, varid, start, edges,
08038                          stride, 0, value);
08039 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8003 of file putget.c. References nc_get_varm_short(), and stride. 
 08010 {
08011         return nc_get_varm_short (ncid, varid, start, edges,
08012                          stride, 0, value);
08013 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 7963 of file putget.c. References nc_get_varm_text(), and stride. 
 07970 {
07971         return nc_get_varm_text (ncid, varid, start, edges,
07972                          stride, 0, value);
07973 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 1116 of file nc.c. References NC::attrs, NC::dims, find_NC_Udim(), NC_check_id(), NC_attrarray::nelems, NC_vararray::nelems, NC_dimarray::nelems, and NC::vars. Referenced by do_ncdump(), main(), and ncinquire(). 
 01121 {
01122         int status;
01123         NC *ncp;
01124 
01125         status = NC_check_id(ncid, &ncp); 
01126         if(status != NC_NOERR)
01127                 return status;
01128 
01129         if(ndimsp != NULL)
01130                 *ndimsp = (int) ncp->dims.nelems;
01131         if(nvarsp != NULL)
01132                 *nvarsp = (int) ncp->vars.nelems;
01133         if(nattsp != NULL)
01134                 *nattsp = (int) ncp->attrs.nelems;
01135         if(xtendimp != NULL)
01136                 *xtendimp = find_NC_Udim(&ncp->dims, NULL);
01137 
01138         return NC_NOERR;
01139 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 466 of file attr.c. References name, NC_lookupattr(), NC_attr::nelems, and NC_attr::type. Referenced by do_ncdump(), has_c_format_att(), main(), ncattinq(), and pr_att(). 
 00471 {
00472         int status;
00473         NC_attr *attrp;
00474 
00475         status = NC_lookupattr(ncid, varid, name, &attrp);
00476         if(status != NC_NOERR)
00477                 return status;
00478 
00479         if(datatypep != NULL)
00480                 *datatypep = attrp->type;
00481         if(lenp != NULL)
00482                 *lenp = attrp->nelems;
00483 
00484         return NC_NOERR;
00485 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 407 of file attr.c. References name, NC_attrarray0(), NC_check_id(), NC_findattr(), and NC_attrarray::value. 
 00408 {
00409         int status;
00410         NC *ncp;
00411         NC_attrarray *ncap;
00412         NC_attr **attrpp;
00413 
00414         status = NC_check_id(ncid, &ncp);
00415         if(status != NC_NOERR)
00416                 return status;
00417 
00418         ncap = NC_attrarray0(ncp, varid);
00419         if(ncap == NULL)
00420                 return NC_ENOTVAR;
00421         
00422 
00423         attrpp = NC_findattr(ncap, name);
00424         if(attrpp == NULL)
00425                 return NC_ENOTATT;
00426 
00427         if(attnump != NULL)
00428                 *attnump = (int)(attrpp - ncap->value);
00429 
00430         return NC_NOERR;
00431 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 450 of file attr.c. References name, NC_lookupattr(), and NC_attr::nelems. Referenced by read_mincdim(), and THD_open_minc(). 
 00451 {
00452         int status;
00453         NC_attr *attrp;
00454 
00455         status = NC_lookupattr(ncid, varid, name, &attrp);
00456         if(status != NC_NOERR)
00457                 return status;
00458 
00459         if(lenp != NULL)
00460                 *lenp = attrp->nelems;
00461 
00462         return NC_NOERR;
00463 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 380 of file attr.c. References NC_string::cp, elem_NC_attrarray(), NC_attr::name, name, NC_attrarray0(), NC_check_id(), and NC_string::nchars. Referenced by main(), ncattname(), and pr_att(). 
 00381 {
00382         int status;
00383         NC *ncp;
00384         NC_attrarray *ncap;
00385         NC_attr *attrp;
00386 
00387         status = NC_check_id(ncid, &ncp);
00388         if(status != NC_NOERR)
00389                 return status;
00390 
00391         ncap = NC_attrarray0(ncp, varid);
00392         if(ncap == NULL)
00393                 return NC_ENOTVAR;
00394 
00395         attrp = elem_NC_attrarray(ncap, (size_t)attnum);
00396         if(attrp == NULL)
00397                 return NC_ENOTATT;
00398 
00399         (void) strncpy(name, attrp->name->cp, attrp->name->nchars);
00400         name[attrp->name->nchars] = 0;
00401 
00402         return NC_NOERR;
00403 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 434 of file attr.c. References name, NC_lookupattr(), and NC_attr::type. 
 00435 {
00436         int status;
00437         NC_attr *attrp;
00438 
00439         status = NC_lookupattr(ncid, varid, name, &attrp);
00440         if(status != NC_NOERR)
00441                 return status;
00442 
00443         if(datatypep != NULL)
00444                 *datatypep = attrp->type;
00445 
00446         return NC_NOERR;
00447 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1350 of file nc.c. References NC_check_id(). 
 01351 {
01352 #if _CRAYMPP && defined(LOCKNUMREC)
01353         int status;
01354         NC *ncp;
01355 
01356         if ((status = NC_check_id(ncid, &ncp)) != NC_NOERR) {
01357                 return status;
01358         }
01359 
01360         *pe = (int) ncp->lock[LOCKNUMREC_BASEPE];
01361 #else
01362         /*
01363          * !_CRAYMPP, only pe 0 is valid
01364          */
01365         *pe = 0;
01366 #endif /* _CRAYMPP && LOCKNUMREC */
01367         return NC_NOERR;
01368 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 382 of file dim.c. References NC_string::cp, NC::dims, elem_NC_dimarray(), NC_dim::name, name, NC_check_id(), NC_get_numrecs, NC_string::nchars, and NC_dim::size. Referenced by do_ncdump(), main(), ncdiminq(), and testdims(). 
 00383 {
00384         int status;
00385         NC *ncp;
00386         NC_dim *dimp;
00387 
00388         status = NC_check_id(ncid, &ncp); 
00389         if(status != NC_NOERR)
00390                 return status;
00391 
00392         dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
00393         if(dimp == NULL)
00394                 return NC_EBADDIM;
00395 
00396         if(name != NULL)
00397         {
00398                 (void)strncpy(name, dimp->name->cp, 
00399                         dimp->name->nchars);
00400                 name[dimp->name->nchars] = 0;
00401         }
00402         if(sizep != 0)
00403         {
00404                 if(dimp->size == NC_UNLIMITED)
00405                         *sizep = NC_get_numrecs(ncp);
00406                 else
00407                         *sizep = dimp->size;    
00408         }
00409         return NC_NOERR;
00410 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 361 of file dim.c. References NC::dims, name, NC_check_id(), and NC_finddim(). Referenced by ncdimid(), and read_mincdim(). 
 00362 {
00363         int status;
00364         NC *ncp;
00365         int dimid;
00366 
00367         status = NC_check_id(ncid, &ncp); 
00368         if(status != NC_NOERR)
00369                 return status;
00370 
00371         dimid = NC_finddim(&ncp->dims, name, NULL);
00372 
00373         if(dimid == -1)
00374                 return NC_EBADDIM;
00375 
00376         *dimid_ptr = dimid;
00377         return NC_NOERR;
00378 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 440 of file dim.c. References NC::dims, elem_NC_dimarray(), NC_check_id(), NC_get_numrecs, and NC_dim::size. Referenced by read_mincdim(), and THD_open_minc(). 
 00441 {
00442         int status;
00443         NC *ncp;
00444         NC_dim *dimp;
00445 
00446         status = NC_check_id(ncid, &ncp); 
00447         if(status != NC_NOERR)
00448                 return status;
00449 
00450         dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
00451         if(dimp == NULL)
00452                 return NC_EBADDIM;
00453 
00454         if(lenp != 0)
00455         {
00456                 if(dimp->size == NC_UNLIMITED)
00457                         *lenp = NC_get_numrecs(ncp);
00458                 else
00459                         *lenp = dimp->size;     
00460         }
00461         return NC_NOERR;
00462 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 414 of file dim.c. References NC_string::cp, NC::dims, elem_NC_dimarray(), NC_dim::name, name, NC_check_id(), and NC_string::nchars. Referenced by THD_open_minc(). 
 00415 {
00416         int status;
00417         NC *ncp;
00418         NC_dim *dimp;
00419 
00420         status = NC_check_id(ncid, &ncp); 
00421         if(status != NC_NOERR)
00422                 return status;
00423 
00424         dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
00425         if(dimp == NULL)
00426                 return NC_EBADDIM;
00427 
00428         if(name != NULL)
00429         {
00430                 (void)strncpy(name, dimp->name->cp, 
00431                         dimp->name->nchars);
00432                 name[dimp->name->nchars] = 0;
00433         }
00434 
00435         return NC_NOERR;
00436 }
 | 
| 
 | 
| 
 Definition at line 18 of file libvers.c. References nc_libvers, and SKIP_LEADING_GARBAGE. Referenced by usage(). 
 00019 {
00020         return &nc_libvers[SKIP_LEADING_GARBAGE];
00021 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1174 of file nc.c. References NC::attrs, NC_check_id(), and NC_attrarray::nelems. Referenced by nc_inq_varnatts(). 
 01175 {
01176         int status;
01177         NC *ncp;
01178 
01179         status = NC_check_id(ncid, &ncp); 
01180         if(status != NC_NOERR)
01181                 return status;
01182 
01183         if(nattsp != NULL)
01184                 *nattsp = (int) ncp->attrs.nelems;
01185 
01186         return NC_NOERR;
01187 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1142 of file nc.c. References NC::dims, NC_check_id(), and NC_dimarray::nelems. 
 01143 {
01144         int status;
01145         NC *ncp;
01146 
01147         status = NC_check_id(ncid, &ncp); 
01148         if(status != NC_NOERR)
01149                 return status;
01150 
01151         if(ndimsp != NULL)
01152                 *ndimsp = (int) ncp->dims.nelems;
01153 
01154         return NC_NOERR;
01155 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1158 of file nc.c. References NC_check_id(), NC_vararray::nelems, and NC::vars. 
 01159 {
01160         int status;
01161         NC *ncp;
01162 
01163         status = NC_check_id(ncid, &ncp); 
01164         if(status != NC_NOERR)
01165                 return status;
01166 
01167         if(nvarsp != NULL)
01168                 *nvarsp = (int) ncp->vars.nelems;
01169 
01170         return NC_NOERR;
01171 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1190 of file nc.c. References NC::dims, find_NC_Udim(), and NC_check_id(). 
 01191 {
01192         int status;
01193         NC *ncp;
01194 
01195         status = NC_check_id(ncid, &ncp); 
01196         if(status != NC_NOERR)
01197                 return status;
01198 
01199         if(xtendimp != NULL)
01200                 *xtendimp = find_NC_Udim(&ncp->dims, NULL);
01201 
01202         return NC_NOERR;
01203 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 550 of file var.c. References NC_var::attrs, NC_string::cp, NC_var::dimids, elem_NC_vararray(), NC_var::name, name, NC_check_id(), NC_string::nchars, NC_var::ndims, NC_attrarray::nelems, NC_var::type, and NC::vars. Referenced by do_ncdump(), main(), and ncvarinq(). 
 00557 {
00558         int status;
00559         NC *ncp;
00560         NC_var *varp;
00561         size_t ii;
00562 
00563         status = NC_check_id(ncid, &ncp); 
00564         if(status != NC_NOERR)
00565                 return status;
00566 
00567         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00568         if(varp == NULL)
00569                 return NC_ENOTVAR;
00570 
00571         if(name != NULL)
00572         {
00573                 (void) strncpy(name, varp->name->cp, varp->name->nchars);
00574                 name[varp->name->nchars] = 0;
00575         }
00576 
00577         if(typep != 0)
00578                 *typep = varp->type;
00579         if(ndimsp != 0)
00580         {
00581                 *ndimsp = (int) varp->ndims;
00582         }
00583         if(dimids != 0)
00584         {
00585                 for(ii = 0; ii < varp->ndims; ii++)
00586                 {
00587                         dimids[ii] = varp->dimids[ii];
00588                 }
00589         }
00590         if(nattsp != 0)
00591         {
00592                 *nattsp = (int) varp->attrs.nelems;
00593         }
00594 
00595         return NC_NOERR;
00596 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 669 of file var.c. References NC_var::dimids, elem_NC_vararray(), NC_check_id(), NC_var::ndims, and NC::vars. Referenced by THD_open_minc(). 
 00670 {
00671         int status;
00672         NC *ncp;
00673         NC_var *varp;
00674         size_t ii;
00675 
00676         status = NC_check_id(ncid, &ncp); 
00677         if(status != NC_NOERR)
00678                 return status;
00679 
00680         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00681         if(varp == NULL)
00682                 return NC_ENOTVAR; /* TODO: is this the right error code? */
00683 
00684         if(dimids != 0)
00685         {
00686                 for(ii = 0; ii < varp->ndims; ii++)
00687                 {
00688                         dimids[ii] = varp->dimids[ii];
00689                 }
00690         }
00691 
00692         return NC_NOERR;
00693 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 527 of file var.c. References name, NC_check_id(), NC_findvar(), and NC::vars. Referenced by do_ncdump(), ncvarid(), read_mincdim(), THD_load_minc(), and THD_open_minc(). 
 00528 {
00529         int status;
00530         NC *ncp;
00531         NC_var *varp;
00532         int varid;
00533 
00534         status = NC_check_id(ncid, &ncp); 
00535         if(status != NC_NOERR)
00536                 return status;
00537 
00538         varid = NC_findvar(&ncp->vars, name, &varp);
00539         if(varid == -1)
00540         {
00541                 return NC_ENOTVAR;
00542         }
00543 
00544         *varid_ptr = varid;
00545         return NC_NOERR;
00546 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 600 of file var.c. References NC_string::cp, elem_NC_vararray(), NC_var::name, name, NC_check_id(), NC_string::nchars, and NC::vars. 
 00601 {
00602         int status;
00603         NC *ncp;
00604         NC_var *varp;
00605 
00606         status = NC_check_id(ncid, &ncp); 
00607         if(status != NC_NOERR)
00608                 return status;
00609 
00610         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00611         if(varp == NULL)
00612                 return NC_ENOTVAR;
00613 
00614         if(name != NULL)
00615         {
00616                 (void) strncpy(name, varp->name->cp, varp->name->nchars);
00617                 name[varp->name->nchars] = 0;
00618         }
00619 
00620         return NC_NOERR;
00621 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 697 of file var.c. References NC_var::attrs, elem_NC_vararray(), NC_check_id(), nc_inq_natts(), NC_attrarray::nelems, and NC::vars. 
 00698 {
00699         int status;
00700         NC *ncp;
00701         NC_var *varp;
00702 
00703         if(varid == NC_GLOBAL)
00704                 return  nc_inq_natts(ncid, nattsp);
00705 
00706         status = NC_check_id(ncid, &ncp); 
00707         if(status != NC_NOERR)
00708                 return status;
00709 
00710         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00711         if(varp == NULL)
00712                 return NC_ENOTVAR; /* TODO: is this the right error code? */
00713 
00714         if(nattsp != 0)
00715         {
00716                 *nattsp = (int) varp->attrs.nelems;
00717         }
00718 
00719         return NC_NOERR;
00720 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 645 of file var.c. References elem_NC_vararray(), NC_check_id(), NC_var::ndims, and NC::vars. Referenced by THD_open_minc(). 
 00646 {
00647         int status;
00648         NC *ncp;
00649         NC_var *varp;
00650 
00651         status = NC_check_id(ncid, &ncp); 
00652         if(status != NC_NOERR)
00653                 return status;
00654 
00655         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00656         if(varp == NULL)
00657                 return NC_ENOTVAR; /* TODO: is this the right error code? */
00658 
00659         if(ndimsp != 0)
00660         {
00661                 *ndimsp = (int) varp->ndims;
00662         }
00663 
00664         return NC_NOERR;
00665 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 624 of file var.c. References elem_NC_vararray(), NC_check_id(), NC_var::type, and NC::vars. Referenced by THD_load_minc(), and THD_open_minc(). 
 00625 {
00626         int status;
00627         NC *ncp;
00628         NC_var *varp;
00629 
00630         status = NC_check_id(ncid, &ncp); 
00631         if(status != NC_NOERR)
00632                 return status;
00633 
00634         varp = elem_NC_vararray(&ncp->vars, (size_t)varid);
00635         if(varp == NULL)
00636                 return NC_ENOTVAR;
00637 
00638         if(typep != 0)
00639                 *typep = varp->type;
00640 
00641         return NC_NOERR;
00642 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 901 of file nc.c. References nc__open(). Referenced by do_ncdump(), ncopen(), THD_load_minc(), and THD_open_minc(). 
 00902 {
00903         return nc__open(path, ioflags, NULL, ncid_ptr);
00904 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2026 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Idouble(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by createtestvars(), main(), and nc_put_att(). 
 02028 {
02029         int status;
02030         NC *ncp;
02031         NC_attrarray *ncap;
02032         NC_attr **attrpp;
02033         NC_attr *old = NULL;
02034         NC_attr *attrp;
02035 
02036         status = NC_check_id(ncid, &ncp);
02037         if(status != NC_NOERR)
02038                 return status;
02039 
02040         if(NC_readonly(ncp))
02041                 return NC_EPERM;
02042 
02043         ncap = NC_attrarray0(ncp, varid);
02044         if(ncap == NULL)
02045                 return NC_ENOTVAR;
02046 
02047         status = nc_cktype(type);
02048         if(status != NC_NOERR)
02049                 return status;
02050 
02051         if(type == NC_CHAR)
02052                 return NC_ECHAR;
02053 
02054                 /* cast needed for braindead systems with signed size_t */
02055         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
02056                 return NC_EINVAL; /* Invalid nelems */
02057 
02058         if(nelems != 0 && value == NULL)
02059                 return NC_EINVAL; /* Null arg */
02060 
02061         attrpp = NC_findattr(ncap, name);
02062         if(attrpp != NULL) /* name in use */
02063         {
02064                 if(!NC_indef(ncp) )
02065                 {
02066                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
02067                         attrp = *attrpp; /* convenience */
02068         
02069                         if(xsz > attrp->xsz)
02070                                 return NC_ENOTINDEFINE;
02071                         /* else, we can reuse existing without redef */
02072                         
02073                         attrp->xsz = xsz;
02074                         attrp->type = type;
02075                         attrp->nelems = nelems;
02076 
02077                         if(nelems != 0)
02078                         {
02079                                 void *xp = attrp->xvalue;
02080                                 status = ncx_pad_putn_Idouble(&xp, nelems,
02081                                         value, type);
02082                         }
02083                         
02084                         set_NC_hdirty(ncp);
02085 
02086                         if(NC_doHsync(ncp))
02087                         {
02088                                 const int lstatus = NC_sync(ncp);
02089                                 /*
02090                                  * N.B.: potentially overrides NC_ERANGE
02091                                  * set by ncx_pad_putn_Idouble
02092                                  */
02093                                 if(lstatus != ENOERR)
02094                                         return lstatus;
02095                         }
02096 
02097                         return status;
02098                 }
02099                 /* else, redefine using existing array slot */
02100                 old = *attrpp;
02101         } 
02102         else
02103         {
02104                 if(!NC_indef(ncp))
02105                         return NC_ENOTINDEFINE;
02106 
02107                 if(ncap->nelems >= NC_MAX_ATTRS)
02108                         return NC_EMAXATTS;
02109         }
02110 
02111         status = NC_check_name(name);
02112         if(status != NC_NOERR)
02113                 return status;
02114 
02115         attrp = new_NC_attr(name, type, nelems);
02116         if(attrp == NULL)
02117                 return NC_ENOMEM;
02118 
02119         if(nelems != 0)
02120         {
02121                 void *xp = attrp->xvalue;
02122                 status = ncx_pad_putn_Idouble(&xp, nelems,
02123                         value, type);
02124         }
02125 
02126         if(attrpp != NULL)
02127         {
02128                 assert(old != NULL);
02129                 *attrpp = attrp;
02130                 free_NC_attr(old);
02131         }
02132         else
02133         {
02134                 const int lstatus = incr_NC_attrarray(ncap, attrp);
02135                 /*
02136                  * N.B.: potentially overrides NC_ERANGE
02137                  * set by ncx_pad_putn_Idouble
02138                  */
02139                 if(lstatus != NC_NOERR)
02140                 {
02141                         free_NC_attr(attrp);
02142                         return lstatus;
02143                 }
02144         }
02145 
02146         return status;
02147 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1879 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Ifloat(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by nc_put_att(). 
 01881 {
01882         int status;
01883         NC *ncp;
01884         NC_attrarray *ncap;
01885         NC_attr **attrpp;
01886         NC_attr *old = NULL;
01887         NC_attr *attrp;
01888 
01889         status = NC_check_id(ncid, &ncp);
01890         if(status != NC_NOERR)
01891                 return status;
01892 
01893         if(NC_readonly(ncp))
01894                 return NC_EPERM;
01895 
01896         ncap = NC_attrarray0(ncp, varid);
01897         if(ncap == NULL)
01898                 return NC_ENOTVAR;
01899 
01900         status = nc_cktype(type);
01901         if(status != NC_NOERR)
01902                 return status;
01903 
01904         if(type == NC_CHAR)
01905                 return NC_ECHAR;
01906 
01907                 /* cast needed for braindead systems with signed size_t */
01908         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01909                 return NC_EINVAL; /* Invalid nelems */
01910 
01911         if(nelems != 0 && value == NULL)
01912                 return NC_EINVAL; /* Null arg */
01913 
01914         attrpp = NC_findattr(ncap, name);
01915         if(attrpp != NULL) /* name in use */
01916         {
01917                 if(!NC_indef(ncp) )
01918                 {
01919                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01920                         attrp = *attrpp; /* convenience */
01921         
01922                         if(xsz > attrp->xsz)
01923                                 return NC_ENOTINDEFINE;
01924                         /* else, we can reuse existing without redef */
01925                         
01926                         attrp->xsz = xsz;
01927                         attrp->type = type;
01928                         attrp->nelems = nelems;
01929 
01930                         if(nelems != 0)
01931                         {
01932                                 void *xp = attrp->xvalue;
01933                                 status = ncx_pad_putn_Ifloat(&xp, nelems,
01934                                         value, type);
01935                         }
01936                         
01937                         set_NC_hdirty(ncp);
01938 
01939                         if(NC_doHsync(ncp))
01940                         {
01941                                 const int lstatus = NC_sync(ncp);
01942                                 /*
01943                                  * N.B.: potentially overrides NC_ERANGE
01944                                  * set by ncx_pad_putn_Ifloat
01945                                  */
01946                                 if(lstatus != ENOERR)
01947                                         return lstatus;
01948                         }
01949 
01950                         return status;
01951                 }
01952                 /* else, redefine using existing array slot */
01953                 old = *attrpp;
01954         } 
01955         else
01956         {
01957                 if(!NC_indef(ncp))
01958                         return NC_ENOTINDEFINE;
01959 
01960                 if(ncap->nelems >= NC_MAX_ATTRS)
01961                         return NC_EMAXATTS;
01962         }
01963 
01964         status = NC_check_name(name);
01965         if(status != NC_NOERR)
01966                 return status;
01967 
01968         attrp = new_NC_attr(name, type, nelems);
01969         if(attrp == NULL)
01970                 return NC_ENOMEM;
01971 
01972         if(nelems != 0)
01973         {
01974                 void *xp = attrp->xvalue;
01975                 status = ncx_pad_putn_Ifloat(&xp, nelems,
01976                         value, type);
01977         }
01978 
01979         if(attrpp != NULL)
01980         {
01981                 assert(old != NULL);
01982                 *attrpp = attrp;
01983                 free_NC_attr(old);
01984         }
01985         else
01986         {
01987                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01988                 /*
01989                  * N.B.: potentially overrides NC_ERANGE
01990                  * set by ncx_pad_putn_Ifloat
01991                  */
01992                 if(lstatus != NC_NOERR)
01993                 {
01994                         free_NC_attr(attrp);
01995                         return lstatus;
01996                 }
01997         }
01998 
01999         return status;
02000 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1585 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Iint(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by main(), and nc_put_att(). 
 01587 {
01588         int status;
01589         NC *ncp;
01590         NC_attrarray *ncap;
01591         NC_attr **attrpp;
01592         NC_attr *old = NULL;
01593         NC_attr *attrp;
01594 
01595         status = NC_check_id(ncid, &ncp);
01596         if(status != NC_NOERR)
01597                 return status;
01598 
01599         if(NC_readonly(ncp))
01600                 return NC_EPERM;
01601 
01602         ncap = NC_attrarray0(ncp, varid);
01603         if(ncap == NULL)
01604                 return NC_ENOTVAR;
01605 
01606         status = nc_cktype(type);
01607         if(status != NC_NOERR)
01608                 return status;
01609 
01610         if(type == NC_CHAR)
01611                 return NC_ECHAR;
01612 
01613                 /* cast needed for braindead systems with signed size_t */
01614         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01615                 return NC_EINVAL; /* Invalid nelems */
01616 
01617         if(nelems != 0 && value == NULL)
01618                 return NC_EINVAL; /* Null arg */
01619 
01620         attrpp = NC_findattr(ncap, name);
01621         if(attrpp != NULL) /* name in use */
01622         {
01623                 if(!NC_indef(ncp) )
01624                 {
01625                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01626                         attrp = *attrpp; /* convenience */
01627         
01628                         if(xsz > attrp->xsz)
01629                                 return NC_ENOTINDEFINE;
01630                         /* else, we can reuse existing without redef */
01631                         
01632                         attrp->xsz = xsz;
01633                         attrp->type = type;
01634                         attrp->nelems = nelems;
01635 
01636                         if(nelems != 0)
01637                         {
01638                                 void *xp = attrp->xvalue;
01639                                 status = ncx_pad_putn_Iint(&xp, nelems,
01640                                         value, type);
01641                         }
01642                         
01643                         set_NC_hdirty(ncp);
01644 
01645                         if(NC_doHsync(ncp))
01646                         {
01647                                 const int lstatus = NC_sync(ncp);
01648                                 /*
01649                                  * N.B.: potentially overrides NC_ERANGE
01650                                  * set by ncx_pad_putn_Iint
01651                                  */
01652                                 if(lstatus != ENOERR)
01653                                         return lstatus;
01654                         }
01655 
01656                         return status;
01657                 }
01658                 /* else, redefine using existing array slot */
01659                 old = *attrpp;
01660         } 
01661         else
01662         {
01663                 if(!NC_indef(ncp))
01664                         return NC_ENOTINDEFINE;
01665 
01666                 if(ncap->nelems >= NC_MAX_ATTRS)
01667                         return NC_EMAXATTS;
01668         }
01669 
01670         status = NC_check_name(name);
01671         if(status != NC_NOERR)
01672                 return status;
01673 
01674         attrp = new_NC_attr(name, type, nelems);
01675         if(attrp == NULL)
01676                 return NC_ENOMEM;
01677 
01678         if(nelems != 0)
01679         {
01680                 void *xp = attrp->xvalue;
01681                 status = ncx_pad_putn_Iint(&xp, nelems,
01682                         value, type);
01683         }
01684 
01685         if(attrpp != NULL)
01686         {
01687                 assert(old != NULL);
01688                 *attrpp = attrp;
01689                 free_NC_attr(old);
01690         }
01691         else
01692         {
01693                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01694                 /*
01695                  * N.B.: potentially overrides NC_ERANGE
01696                  * set by ncx_pad_putn_Iint
01697                  */
01698                 if(lstatus != NC_NOERR)
01699                 {
01700                         free_NC_attr(attrp);
01701                         return lstatus;
01702                 }
01703         }
01704 
01705         return status;
01706 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1732 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Ilong(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by nc_put_att(). 
 01734 {
01735         int status;
01736         NC *ncp;
01737         NC_attrarray *ncap;
01738         NC_attr **attrpp;
01739         NC_attr *old = NULL;
01740         NC_attr *attrp;
01741 
01742         status = NC_check_id(ncid, &ncp);
01743         if(status != NC_NOERR)
01744                 return status;
01745 
01746         if(NC_readonly(ncp))
01747                 return NC_EPERM;
01748 
01749         ncap = NC_attrarray0(ncp, varid);
01750         if(ncap == NULL)
01751                 return NC_ENOTVAR;
01752 
01753         status = nc_cktype(type);
01754         if(status != NC_NOERR)
01755                 return status;
01756 
01757         if(type == NC_CHAR)
01758                 return NC_ECHAR;
01759 
01760                 /* cast needed for braindead systems with signed size_t */
01761         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01762                 return NC_EINVAL; /* Invalid nelems */
01763 
01764         if(nelems != 0 && value == NULL)
01765                 return NC_EINVAL; /* Null arg */
01766 
01767         attrpp = NC_findattr(ncap, name);
01768         if(attrpp != NULL) /* name in use */
01769         {
01770                 if(!NC_indef(ncp) )
01771                 {
01772                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01773                         attrp = *attrpp; /* convenience */
01774         
01775                         if(xsz > attrp->xsz)
01776                                 return NC_ENOTINDEFINE;
01777                         /* else, we can reuse existing without redef */
01778                         
01779                         attrp->xsz = xsz;
01780                         attrp->type = type;
01781                         attrp->nelems = nelems;
01782 
01783                         if(nelems != 0)
01784                         {
01785                                 void *xp = attrp->xvalue;
01786                                 status = ncx_pad_putn_Ilong(&xp, nelems,
01787                                         value, type);
01788                         }
01789                         
01790                         set_NC_hdirty(ncp);
01791 
01792                         if(NC_doHsync(ncp))
01793                         {
01794                                 const int lstatus = NC_sync(ncp);
01795                                 /*
01796                                  * N.B.: potentially overrides NC_ERANGE
01797                                  * set by ncx_pad_putn_Ilong
01798                                  */
01799                                 if(lstatus != ENOERR)
01800                                         return lstatus;
01801                         }
01802 
01803                         return status;
01804                 }
01805                 /* else, redefine using existing array slot */
01806                 old = *attrpp;
01807         } 
01808         else
01809         {
01810                 if(!NC_indef(ncp))
01811                         return NC_ENOTINDEFINE;
01812 
01813                 if(ncap->nelems >= NC_MAX_ATTRS)
01814                         return NC_EMAXATTS;
01815         }
01816 
01817         status = NC_check_name(name);
01818         if(status != NC_NOERR)
01819                 return status;
01820 
01821         attrp = new_NC_attr(name, type, nelems);
01822         if(attrp == NULL)
01823                 return NC_ENOMEM;
01824 
01825         if(nelems != 0)
01826         {
01827                 void *xp = attrp->xvalue;
01828                 status = ncx_pad_putn_Ilong(&xp, nelems,
01829                         value, type);
01830         }
01831 
01832         if(attrpp != NULL)
01833         {
01834                 assert(old != NULL);
01835                 *attrpp = attrp;
01836                 free_NC_attr(old);
01837         }
01838         else
01839         {
01840                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01841                 /*
01842                  * N.B.: potentially overrides NC_ERANGE
01843                  * set by ncx_pad_putn_Ilong
01844                  */
01845                 if(lstatus != NC_NOERR)
01846                 {
01847                         free_NC_attr(attrp);
01848                         return lstatus;
01849                 }
01850         }
01851 
01852         return status;
01853 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1144 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Ischar(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by nc_put_att(). 
 01146 {
01147         int status;
01148         NC *ncp;
01149         NC_attrarray *ncap;
01150         NC_attr **attrpp;
01151         NC_attr *old = NULL;
01152         NC_attr *attrp;
01153 
01154         status = NC_check_id(ncid, &ncp);
01155         if(status != NC_NOERR)
01156                 return status;
01157 
01158         if(NC_readonly(ncp))
01159                 return NC_EPERM;
01160 
01161         ncap = NC_attrarray0(ncp, varid);
01162         if(ncap == NULL)
01163                 return NC_ENOTVAR;
01164 
01165         status = nc_cktype(type);
01166         if(status != NC_NOERR)
01167                 return status;
01168 
01169         if(type == NC_CHAR)
01170                 return NC_ECHAR;
01171 
01172                 /* cast needed for braindead systems with signed size_t */
01173         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01174                 return NC_EINVAL; /* Invalid nelems */
01175 
01176         if(nelems != 0 && value == NULL)
01177                 return NC_EINVAL; /* Null arg */
01178 
01179         attrpp = NC_findattr(ncap, name);
01180         if(attrpp != NULL) /* name in use */
01181         {
01182                 if(!NC_indef(ncp) )
01183                 {
01184                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01185                         attrp = *attrpp; /* convenience */
01186         
01187                         if(xsz > attrp->xsz)
01188                                 return NC_ENOTINDEFINE;
01189                         /* else, we can reuse existing without redef */
01190                         
01191                         attrp->xsz = xsz;
01192                         attrp->type = type;
01193                         attrp->nelems = nelems;
01194 
01195                         if(nelems != 0)
01196                         {
01197                                 void *xp = attrp->xvalue;
01198                                 status = ncx_pad_putn_Ischar(&xp, nelems,
01199                                         value, type);
01200                         }
01201                         
01202                         set_NC_hdirty(ncp);
01203 
01204                         if(NC_doHsync(ncp))
01205                         {
01206                                 const int lstatus = NC_sync(ncp);
01207                                 /*
01208                                  * N.B.: potentially overrides NC_ERANGE
01209                                  * set by ncx_pad_putn_Ischar
01210                                  */
01211                                 if(lstatus != ENOERR)
01212                                         return lstatus;
01213                         }
01214 
01215                         return status;
01216                 }
01217                 /* else, redefine using existing array slot */
01218                 old = *attrpp;
01219         } 
01220         else
01221         {
01222                 if(!NC_indef(ncp))
01223                         return NC_ENOTINDEFINE;
01224 
01225                 if(ncap->nelems >= NC_MAX_ATTRS)
01226                         return NC_EMAXATTS;
01227         }
01228 
01229         status = NC_check_name(name);
01230         if(status != NC_NOERR)
01231                 return status;
01232 
01233         attrp = new_NC_attr(name, type, nelems);
01234         if(attrp == NULL)
01235                 return NC_ENOMEM;
01236 
01237         if(nelems != 0)
01238         {
01239                 void *xp = attrp->xvalue;
01240                 status = ncx_pad_putn_Ischar(&xp, nelems,
01241                         value, type);
01242         }
01243 
01244         if(attrpp != NULL)
01245         {
01246                 assert(old != NULL);
01247                 *attrpp = attrp;
01248                 free_NC_attr(old);
01249         }
01250         else
01251         {
01252                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01253                 /*
01254                  * N.B.: potentially overrides NC_ERANGE
01255                  * set by ncx_pad_putn_Ischar
01256                  */
01257                 if(lstatus != NC_NOERR)
01258                 {
01259                         free_NC_attr(attrp);
01260                         return lstatus;
01261                 }
01262         }
01263 
01264         return status;
01265 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1438 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Ishort(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by nc_put_att(). 
 01440 {
01441         int status;
01442         NC *ncp;
01443         NC_attrarray *ncap;
01444         NC_attr **attrpp;
01445         NC_attr *old = NULL;
01446         NC_attr *attrp;
01447 
01448         status = NC_check_id(ncid, &ncp);
01449         if(status != NC_NOERR)
01450                 return status;
01451 
01452         if(NC_readonly(ncp))
01453                 return NC_EPERM;
01454 
01455         ncap = NC_attrarray0(ncp, varid);
01456         if(ncap == NULL)
01457                 return NC_ENOTVAR;
01458 
01459         status = nc_cktype(type);
01460         if(status != NC_NOERR)
01461                 return status;
01462 
01463         if(type == NC_CHAR)
01464                 return NC_ECHAR;
01465 
01466                 /* cast needed for braindead systems with signed size_t */
01467         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01468                 return NC_EINVAL; /* Invalid nelems */
01469 
01470         if(nelems != 0 && value == NULL)
01471                 return NC_EINVAL; /* Null arg */
01472 
01473         attrpp = NC_findattr(ncap, name);
01474         if(attrpp != NULL) /* name in use */
01475         {
01476                 if(!NC_indef(ncp) )
01477                 {
01478                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01479                         attrp = *attrpp; /* convenience */
01480         
01481                         if(xsz > attrp->xsz)
01482                                 return NC_ENOTINDEFINE;
01483                         /* else, we can reuse existing without redef */
01484                         
01485                         attrp->xsz = xsz;
01486                         attrp->type = type;
01487                         attrp->nelems = nelems;
01488 
01489                         if(nelems != 0)
01490                         {
01491                                 void *xp = attrp->xvalue;
01492                                 status = ncx_pad_putn_Ishort(&xp, nelems,
01493                                         value, type);
01494                         }
01495                         
01496                         set_NC_hdirty(ncp);
01497 
01498                         if(NC_doHsync(ncp))
01499                         {
01500                                 const int lstatus = NC_sync(ncp);
01501                                 /*
01502                                  * N.B.: potentially overrides NC_ERANGE
01503                                  * set by ncx_pad_putn_Ishort
01504                                  */
01505                                 if(lstatus != ENOERR)
01506                                         return lstatus;
01507                         }
01508 
01509                         return status;
01510                 }
01511                 /* else, redefine using existing array slot */
01512                 old = *attrpp;
01513         } 
01514         else
01515         {
01516                 if(!NC_indef(ncp))
01517                         return NC_ENOTINDEFINE;
01518 
01519                 if(ncap->nelems >= NC_MAX_ATTRS)
01520                         return NC_EMAXATTS;
01521         }
01522 
01523         status = NC_check_name(name);
01524         if(status != NC_NOERR)
01525                 return status;
01526 
01527         attrp = new_NC_attr(name, type, nelems);
01528         if(attrp == NULL)
01529                 return NC_ENOMEM;
01530 
01531         if(nelems != 0)
01532         {
01533                 void *xp = attrp->xvalue;
01534                 status = ncx_pad_putn_Ishort(&xp, nelems,
01535                         value, type);
01536         }
01537 
01538         if(attrpp != NULL)
01539         {
01540                 assert(old != NULL);
01541                 *attrpp = attrp;
01542                 free_NC_attr(old);
01543         }
01544         else
01545         {
01546                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01547                 /*
01548                  * N.B.: potentially overrides NC_ERANGE
01549                  * set by ncx_pad_putn_Ishort
01550                  */
01551                 if(lstatus != NC_NOERR)
01552                 {
01553                         free_NC_attr(attrp);
01554                         return lstatus;
01555                 }
01556         }
01557 
01558         return status;
01559 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 1006 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_text(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. Referenced by createtestvars(), main(), and nc_put_att(). 
 01008 {
01009         int status;
01010         NC *ncp;
01011         NC_attrarray *ncap;
01012         NC_attr **attrpp;
01013         NC_attr *old = NULL;
01014         NC_attr *attrp;
01015 
01016         status = NC_check_id(ncid, &ncp);
01017         if(status != NC_NOERR)
01018                 return status;
01019 
01020         if(NC_readonly(ncp))
01021                 return NC_EPERM;
01022 
01023         ncap = NC_attrarray0(ncp, varid);
01024         if(ncap == NULL)
01025                 return NC_ENOTVAR;
01026 
01027         status = NC_check_name(name);
01028         if(status != NC_NOERR)
01029                 return status;
01030 
01031                 /* cast needed for braindead systems with signed size_t */
01032         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01033                 return NC_EINVAL; /* Invalid nelems */
01034 
01035         if(nelems != 0 && value == NULL)
01036                 return NC_EINVAL; /* Null arg */
01037 
01038         attrpp = NC_findattr(ncap, name);
01039         if(attrpp != NULL) /* name in use */
01040         {
01041                 if(!NC_indef(ncp) )
01042                 {
01043                         const size_t xsz = ncx_len_NC_attrV(NC_CHAR, nelems);
01044                         attrp = *attrpp; /* convenience */
01045         
01046                         if(xsz > attrp->xsz)
01047                                 return NC_ENOTINDEFINE;
01048                         /* else, we can reuse existing without redef */
01049                         
01050                         attrp->xsz = xsz;
01051                         attrp->type = NC_CHAR;
01052                         attrp->nelems = nelems;
01053 
01054                         if(nelems != 0)
01055                         {
01056                                 void *xp = attrp->xvalue;
01057                                 status = ncx_pad_putn_text(&xp, nelems, value);
01058                                 if(status != NC_NOERR)
01059                                         return status;
01060                         }
01061                         
01062                         set_NC_hdirty(ncp);
01063 
01064                         if(NC_doHsync(ncp))
01065                         {
01066                                 status = NC_sync(ncp);
01067                                 if(status != NC_NOERR)
01068                                         return status;
01069                         }
01070 
01071                         return NC_NOERR;
01072                 }
01073                 /* else, redefine using existing array slot */
01074                 old = *attrpp;
01075         } 
01076         else
01077         {
01078                 if(!NC_indef(ncp))
01079                         return NC_ENOTINDEFINE;
01080 
01081                 if(ncap->nelems >= NC_MAX_ATTRS)
01082                         return NC_EMAXATTS;
01083         }
01084 
01085         attrp = new_NC_attr(name, NC_CHAR, nelems);
01086         if(attrp == NULL)
01087                 return NC_ENOMEM;
01088 
01089         if(nelems != 0)
01090         {
01091                 void *xp = attrp->xvalue;
01092                 status = ncx_pad_putn_text(&xp, nelems, value);
01093                 if(status != NC_NOERR)
01094                         return status;
01095         }
01096 
01097         if(attrpp != NULL)
01098         {
01099                 assert(old != NULL);
01100                 *attrpp = attrp;
01101                 free_NC_attr(old);
01102         }
01103         else
01104         {
01105                 status = incr_NC_attrarray(ncap, attrp);
01106                 if(status != NC_NOERR)
01107                 {
01108                         free_NC_attr(attrp);
01109                         return status;
01110                 }
01111         }
01112 
01113         return NC_NOERR;
01114 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 1291 of file attr.c. References free_NC_attr(), incr_NC_attrarray(), name, NC_attrarray0(), NC_check_id(), NC_check_name(), nc_cktype(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), ncx_len_NC_attrV(), ncx_pad_putn_Iuchar(), NC_attrarray::nelems, NC_attr::nelems, new_NC_attr(), set_NC_hdirty, NC_attr::type, NC_attr::xsz, and NC_attr::xvalue. 
 01293 {
01294         int status;
01295         NC *ncp;
01296         NC_attrarray *ncap;
01297         NC_attr **attrpp;
01298         NC_attr *old = NULL;
01299         NC_attr *attrp;
01300 
01301         status = NC_check_id(ncid, &ncp);
01302         if(status != NC_NOERR)
01303                 return status;
01304 
01305         if(NC_readonly(ncp))
01306                 return NC_EPERM;
01307 
01308         ncap = NC_attrarray0(ncp, varid);
01309         if(ncap == NULL)
01310                 return NC_ENOTVAR;
01311 
01312         status = nc_cktype(type);
01313         if(status != NC_NOERR)
01314                 return status;
01315 
01316         if(type == NC_CHAR)
01317                 return NC_ECHAR;
01318 
01319                 /* cast needed for braindead systems with signed size_t */
01320         if((unsigned long) nelems > X_INT_MAX) /* backward compat */
01321                 return NC_EINVAL; /* Invalid nelems */
01322 
01323         if(nelems != 0 && value == NULL)
01324                 return NC_EINVAL; /* Null arg */
01325 
01326         attrpp = NC_findattr(ncap, name);
01327         if(attrpp != NULL) /* name in use */
01328         {
01329                 if(!NC_indef(ncp) )
01330                 {
01331                         const size_t xsz = ncx_len_NC_attrV(type, nelems);
01332                         attrp = *attrpp; /* convenience */
01333         
01334                         if(xsz > attrp->xsz)
01335                                 return NC_ENOTINDEFINE;
01336                         /* else, we can reuse existing without redef */
01337                         
01338                         attrp->xsz = xsz;
01339                         attrp->type = type;
01340                         attrp->nelems = nelems;
01341 
01342                         if(nelems != 0)
01343                         {
01344                                 void *xp = attrp->xvalue;
01345                                 status = ncx_pad_putn_Iuchar(&xp, nelems,
01346                                         value, type);
01347                         }
01348                         
01349                         set_NC_hdirty(ncp);
01350 
01351                         if(NC_doHsync(ncp))
01352                         {
01353                                 const int lstatus = NC_sync(ncp);
01354                                 /*
01355                                  * N.B.: potentially overrides NC_ERANGE
01356                                  * set by ncx_pad_putn_Iuchar
01357                                  */
01358                                 if(lstatus != ENOERR)
01359                                         return lstatus;
01360                         }
01361 
01362                         return status;
01363                 }
01364                 /* else, redefine using existing array slot */
01365                 old = *attrpp;
01366         } 
01367         else
01368         {
01369                 if(!NC_indef(ncp))
01370                         return NC_ENOTINDEFINE;
01371 
01372                 if(ncap->nelems >= NC_MAX_ATTRS)
01373                         return NC_EMAXATTS;
01374         }
01375 
01376         status = NC_check_name(name);
01377         if(status != NC_NOERR)
01378                 return status;
01379 
01380         attrp = new_NC_attr(name, type, nelems);
01381         if(attrp == NULL)
01382                 return NC_ENOMEM;
01383 
01384         if(nelems != 0)
01385         {
01386                 void *xp = attrp->xvalue;
01387                 status = ncx_pad_putn_Iuchar(&xp, nelems,
01388                         value, type);
01389         }
01390 
01391         if(attrpp != NULL)
01392         {
01393                 assert(old != NULL);
01394                 *attrpp = attrp;
01395                 free_NC_attr(old);
01396         }
01397         else
01398         {
01399                 const int lstatus = incr_NC_attrarray(ncap, attrp);
01400                 /*
01401                  * N.B.: potentially overrides NC_ERANGE
01402                  * set by ncx_pad_putn_Iuchar
01403                  */
01404                 if(lstatus != NC_NOERR)
01405                 {
01406                         free_NC_attr(attrp);
01407                         return lstatus;
01408                 }
01409         }
01410 
01411         return status;
01412 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4611 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_double(), and NC_var::type. Referenced by main(), and nc_put_var1(). 
 04613 {
04614         int status;
04615         NC *ncp;
04616         const NC_var *varp;
04617 
04618         status = NC_check_id(ncid, &ncp); 
04619         if(status != NC_NOERR)
04620                 return status;
04621 
04622         if(NC_readonly(ncp))
04623                 return NC_EPERM;
04624 
04625         if(NC_indef(ncp))
04626                 return NC_EINDEFINE;
04627 
04628         varp = NC_lookupvar(ncp, varid);
04629         if(varp == NULL)
04630                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04631 
04632         if(varp->type == NC_CHAR)
04633                 return NC_ECHAR;
04634 
04635         status = NCcoordck(ncp, varp, coord);
04636         if(status != NC_NOERR)
04637                 return status;
04638 
04639         if(IS_RECVAR(varp))
04640         {
04641                 status = NCvnrecs(ncp, *coord +1);
04642                 if(status != NC_NOERR)
04643                         return status;
04644         }
04645 
04646         return putNCv_double(ncp, varp, coord, 1, value);
04647 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4572 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_float(), and NC_var::type. Referenced by main(), and nc_put_var1(). 
 04574 {
04575         int status;
04576         NC *ncp;
04577         const NC_var *varp;
04578 
04579         status = NC_check_id(ncid, &ncp); 
04580         if(status != NC_NOERR)
04581                 return status;
04582 
04583         if(NC_readonly(ncp))
04584                 return NC_EPERM;
04585 
04586         if(NC_indef(ncp))
04587                 return NC_EINDEFINE;
04588 
04589         varp = NC_lookupvar(ncp, varid);
04590         if(varp == NULL)
04591                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04592 
04593         if(varp->type == NC_CHAR)
04594                 return NC_ECHAR;
04595 
04596         status = NCcoordck(ncp, varp, coord);
04597         if(status != NC_NOERR)
04598                 return status;
04599 
04600         if(IS_RECVAR(varp))
04601         {
04602                 status = NCvnrecs(ncp, *coord +1);
04603                 if(status != NC_NOERR)
04604                         return status;
04605         }
04606 
04607         return putNCv_float(ncp, varp, coord, 1, value);
04608 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4494 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_int(), and NC_var::type. Referenced by main(), and nc_put_var1(). 
 04496 {
04497         int status;
04498         NC *ncp;
04499         const NC_var *varp;
04500 
04501         status = NC_check_id(ncid, &ncp); 
04502         if(status != NC_NOERR)
04503                 return status;
04504 
04505         if(NC_readonly(ncp))
04506                 return NC_EPERM;
04507 
04508         if(NC_indef(ncp))
04509                 return NC_EINDEFINE;
04510 
04511         varp = NC_lookupvar(ncp, varid);
04512         if(varp == NULL)
04513                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04514 
04515         if(varp->type == NC_CHAR)
04516                 return NC_ECHAR;
04517 
04518         status = NCcoordck(ncp, varp, coord);
04519         if(status != NC_NOERR)
04520                 return status;
04521 
04522         if(IS_RECVAR(varp))
04523         {
04524                 status = NCvnrecs(ncp, *coord +1);
04525                 if(status != NC_NOERR)
04526                         return status;
04527         }
04528 
04529         return putNCv_int(ncp, varp, coord, 1, value);
04530 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4533 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_long(), and NC_var::type. 
 04535 {
04536         int status;
04537         NC *ncp;
04538         const NC_var *varp;
04539 
04540         status = NC_check_id(ncid, &ncp); 
04541         if(status != NC_NOERR)
04542                 return status;
04543 
04544         if(NC_readonly(ncp))
04545                 return NC_EPERM;
04546 
04547         if(NC_indef(ncp))
04548                 return NC_EINDEFINE;
04549 
04550         varp = NC_lookupvar(ncp, varid);
04551         if(varp == NULL)
04552                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04553 
04554         if(varp->type == NC_CHAR)
04555                 return NC_ECHAR;
04556 
04557         status = NCcoordck(ncp, varp, coord);
04558         if(status != NC_NOERR)
04559                 return status;
04560 
04561         if(IS_RECVAR(varp))
04562         {
04563                 status = NCvnrecs(ncp, *coord +1);
04564                 if(status != NC_NOERR)
04565                         return status;
04566         }
04567 
04568         return putNCv_long(ncp, varp, coord, 1, value);
04569 }
 | 
| 
 | ||||||||||||||||||||
| 
 Referenced by main(), and nc_put_var1(). | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4455 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_short(), and NC_var::type. Referenced by main(), and nc_put_var1(). 
 04457 {
04458         int status;
04459         NC *ncp;
04460         const NC_var *varp;
04461 
04462         status = NC_check_id(ncid, &ncp); 
04463         if(status != NC_NOERR)
04464                 return status;
04465 
04466         if(NC_readonly(ncp))
04467                 return NC_EPERM;
04468 
04469         if(NC_indef(ncp))
04470                 return NC_EINDEFINE;
04471 
04472         varp = NC_lookupvar(ncp, varid);
04473         if(varp == NULL)
04474                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04475 
04476         if(varp->type == NC_CHAR)
04477                 return NC_ECHAR;
04478 
04479         status = NCcoordck(ncp, varp, coord);
04480         if(status != NC_NOERR)
04481                 return status;
04482 
04483         if(IS_RECVAR(varp))
04484         {
04485                 status = NCvnrecs(ncp, *coord +1);
04486                 if(status != NC_NOERR)
04487                         return status;
04488         }
04489 
04490         return putNCv_short(ncp, varp, coord, 1, value);
04491 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 4337 of file putget.c. References IS_RECVAR, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCvnrecs(), putNCv_text(), and NC_var::type. Referenced by main(), and nc_put_var1(). 
 04339 {
04340         int status;
04341         NC *ncp;
04342         const NC_var *varp;
04343 
04344         status = NC_check_id(ncid, &ncp); 
04345         if(status != NC_NOERR)
04346                 return status;
04347 
04348         if(NC_readonly(ncp))
04349                 return NC_EPERM;
04350 
04351         if(NC_indef(ncp))
04352                 return NC_EINDEFINE;
04353 
04354         varp = NC_lookupvar(ncp, varid);
04355         if(varp == NULL)
04356                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04357 
04358         if(varp->type != NC_CHAR)
04359                 return NC_ECHAR;
04360 
04361         status = NCcoordck(ncp, varp, coord);
04362         if(status != NC_NOERR)
04363                 return status;
04364 
04365         if(IS_RECVAR(varp))
04366         {
04367                 status = NCvnrecs(ncp, *coord +1);
04368                 if(status != NC_NOERR)
04369                         return status;
04370         }
04371 
04372         return putNCv_text(ncp, varp, coord, 1, value);
04373 }
 | 
| 
 | ||||||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7267 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_double(), NC::recsize, and NC_var::type. 
 07268 {
07269         int status = NC_NOERR;
07270         NC *ncp;
07271         const NC_var *varp;
07272 
07273         status = NC_check_id(ncid, &ncp); 
07274         if(status != NC_NOERR)
07275                 return status;
07276 
07277         if(NC_readonly(ncp))
07278                 return NC_EPERM;
07279 
07280         if(NC_indef(ncp))
07281                 return NC_EINDEFINE;
07282 
07283         varp = NC_lookupvar(ncp, varid);
07284         if(varp == NULL)
07285                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07286 
07287         if(varp->type == NC_CHAR)
07288                 return NC_ECHAR;
07289 
07290         if(varp->ndims == 0) /* scalar variable */
07291         {
07292                 const size_t zed = 0;
07293                 return( putNCv_double(ncp, varp, &zed, 1, value) );
07294         }
07295 
07296         if(!IS_RECVAR(varp))
07297         {
07298                 return(putNCv_double(ncp, varp, coord_zero, *varp->dsizes, value));
07299         }
07300         /* else */
07301 
07302         if(varp->ndims == 1
07303                         && ncp->recsize <= varp->len)
07304         {
07305                 /* one dimensional && the only record variable  */
07306                 return(putNCv_double(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07307                         value));
07308         }
07309         /* else */
07310 
07311         {
07312         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07313         size_t elemsPerRec = 1;
07314         const size_t nrecs = NC_get_numrecs(ncp);
07315         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07316         /* TODO: fix dsizes to avoid this nonsense */
07317         if(varp->ndims > 1)
07318                 elemsPerRec = varp->dsizes[1];
07319         while(*coord < nrecs)
07320         {
07321                 const int lstatus = putNCv_double(ncp, varp, coord, elemsPerRec,
07322                                  value);
07323                 if(lstatus != NC_NOERR)
07324                 {
07325                         if(lstatus != NC_ERANGE)
07326                         {
07327                                 status = lstatus;
07328                                 /* fatal for the loop */
07329                                 break;
07330                         }
07331                         /* else NC_ERANGE, not fatal for the loop */
07332                         if(status == NC_NOERR)
07333                                 status = lstatus;
07334                 }
07335                 value += elemsPerRec;
07336                 (*coord)++;
07337         }
07338         FREE_ONSTACK(coord);
07339         } /* elemsPerRec */
07340 
07341         return status;
07342 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7189 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_float(), NC::recsize, and NC_var::type. 
 07190 {
07191         int status = NC_NOERR;
07192         NC *ncp;
07193         const NC_var *varp;
07194 
07195         status = NC_check_id(ncid, &ncp); 
07196         if(status != NC_NOERR)
07197                 return status;
07198 
07199         if(NC_readonly(ncp))
07200                 return NC_EPERM;
07201 
07202         if(NC_indef(ncp))
07203                 return NC_EINDEFINE;
07204 
07205         varp = NC_lookupvar(ncp, varid);
07206         if(varp == NULL)
07207                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07208 
07209         if(varp->type == NC_CHAR)
07210                 return NC_ECHAR;
07211 
07212         if(varp->ndims == 0) /* scalar variable */
07213         {
07214                 const size_t zed = 0;
07215                 return( putNCv_float(ncp, varp, &zed, 1, value) );
07216         }
07217 
07218         if(!IS_RECVAR(varp))
07219         {
07220                 return(putNCv_float(ncp, varp, coord_zero, *varp->dsizes, value));
07221         }
07222         /* else */
07223 
07224         if(varp->ndims == 1
07225                         && ncp->recsize <= varp->len)
07226         {
07227                 /* one dimensional && the only record variable  */
07228                 return(putNCv_float(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07229                         value));
07230         }
07231         /* else */
07232 
07233         {
07234         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07235         size_t elemsPerRec = 1;
07236         const size_t nrecs = NC_get_numrecs(ncp);
07237         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07238         /* TODO: fix dsizes to avoid this nonsense */
07239         if(varp->ndims > 1)
07240                 elemsPerRec = varp->dsizes[1];
07241         while(*coord < nrecs)
07242         {
07243                 const int lstatus = putNCv_float(ncp, varp, coord, elemsPerRec,
07244                                  value);
07245                 if(lstatus != NC_NOERR)
07246                 {
07247                         if(lstatus != NC_ERANGE)
07248                         {
07249                                 status = lstatus;
07250                                 /* fatal for the loop */
07251                                 break;
07252                         }
07253                         /* else NC_ERANGE, not fatal for the loop */
07254                         if(status == NC_NOERR)
07255                                 status = lstatus;
07256                 }
07257                 value += elemsPerRec;
07258                 (*coord)++;
07259         }
07260         FREE_ONSTACK(coord);
07261         } /* elemsPerRec */
07262 
07263         return status;
07264 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7033 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_int(), NC::recsize, and NC_var::type. 
 07034 {
07035         int status = NC_NOERR;
07036         NC *ncp;
07037         const NC_var *varp;
07038 
07039         status = NC_check_id(ncid, &ncp); 
07040         if(status != NC_NOERR)
07041                 return status;
07042 
07043         if(NC_readonly(ncp))
07044                 return NC_EPERM;
07045 
07046         if(NC_indef(ncp))
07047                 return NC_EINDEFINE;
07048 
07049         varp = NC_lookupvar(ncp, varid);
07050         if(varp == NULL)
07051                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07052 
07053         if(varp->type == NC_CHAR)
07054                 return NC_ECHAR;
07055 
07056         if(varp->ndims == 0) /* scalar variable */
07057         {
07058                 const size_t zed = 0;
07059                 return( putNCv_int(ncp, varp, &zed, 1, value) );
07060         }
07061 
07062         if(!IS_RECVAR(varp))
07063         {
07064                 return(putNCv_int(ncp, varp, coord_zero, *varp->dsizes, value));
07065         }
07066         /* else */
07067 
07068         if(varp->ndims == 1
07069                         && ncp->recsize <= varp->len)
07070         {
07071                 /* one dimensional && the only record variable  */
07072                 return(putNCv_int(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07073                         value));
07074         }
07075         /* else */
07076 
07077         {
07078         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07079         size_t elemsPerRec = 1;
07080         const size_t nrecs = NC_get_numrecs(ncp);
07081         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07082         /* TODO: fix dsizes to avoid this nonsense */
07083         if(varp->ndims > 1)
07084                 elemsPerRec = varp->dsizes[1];
07085         while(*coord < nrecs)
07086         {
07087                 const int lstatus = putNCv_int(ncp, varp, coord, elemsPerRec,
07088                                  value);
07089                 if(lstatus != NC_NOERR)
07090                 {
07091                         if(lstatus != NC_ERANGE)
07092                         {
07093                                 status = lstatus;
07094                                 /* fatal for the loop */
07095                                 break;
07096                         }
07097                         /* else NC_ERANGE, not fatal for the loop */
07098                         if(status == NC_NOERR)
07099                                 status = lstatus;
07100                 }
07101                 value += elemsPerRec;
07102                 (*coord)++;
07103         }
07104         FREE_ONSTACK(coord);
07105         } /* elemsPerRec */
07106 
07107         return status;
07108 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 7111 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_long(), NC::recsize, and NC_var::type. 
 07112 {
07113         int status = NC_NOERR;
07114         NC *ncp;
07115         const NC_var *varp;
07116 
07117         status = NC_check_id(ncid, &ncp); 
07118         if(status != NC_NOERR)
07119                 return status;
07120 
07121         if(NC_readonly(ncp))
07122                 return NC_EPERM;
07123 
07124         if(NC_indef(ncp))
07125                 return NC_EINDEFINE;
07126 
07127         varp = NC_lookupvar(ncp, varid);
07128         if(varp == NULL)
07129                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
07130 
07131         if(varp->type == NC_CHAR)
07132                 return NC_ECHAR;
07133 
07134         if(varp->ndims == 0) /* scalar variable */
07135         {
07136                 const size_t zed = 0;
07137                 return( putNCv_long(ncp, varp, &zed, 1, value) );
07138         }
07139 
07140         if(!IS_RECVAR(varp))
07141         {
07142                 return(putNCv_long(ncp, varp, coord_zero, *varp->dsizes, value));
07143         }
07144         /* else */
07145 
07146         if(varp->ndims == 1
07147                         && ncp->recsize <= varp->len)
07148         {
07149                 /* one dimensional && the only record variable  */
07150                 return(putNCv_long(ncp, varp, coord_zero, NC_get_numrecs(ncp),
07151                         value));
07152         }
07153         /* else */
07154 
07155         {
07156         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07157         size_t elemsPerRec = 1;
07158         const size_t nrecs = NC_get_numrecs(ncp);
07159         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07160         /* TODO: fix dsizes to avoid this nonsense */
07161         if(varp->ndims > 1)
07162                 elemsPerRec = varp->dsizes[1];
07163         while(*coord < nrecs)
07164         {
07165                 const int lstatus = putNCv_long(ncp, varp, coord, elemsPerRec,
07166                                  value);
07167                 if(lstatus != NC_NOERR)
07168                 {
07169                         if(lstatus != NC_ERANGE)
07170                         {
07171                                 status = lstatus;
07172                                 /* fatal for the loop */
07173                                 break;
07174                         }
07175                         /* else NC_ERANGE, not fatal for the loop */
07176                         if(status == NC_NOERR)
07177                                 status = lstatus;
07178                 }
07179                 value += elemsPerRec;
07180                 (*coord)++;
07181         }
07182         FREE_ONSTACK(coord);
07183         } /* elemsPerRec */
07184 
07185         return status;
07186 }
 | 
| 
 | ||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 6955 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_short(), NC::recsize, and NC_var::type. 
 06956 {
06957         int status = NC_NOERR;
06958         NC *ncp;
06959         const NC_var *varp;
06960 
06961         status = NC_check_id(ncid, &ncp); 
06962         if(status != NC_NOERR)
06963                 return status;
06964 
06965         if(NC_readonly(ncp))
06966                 return NC_EPERM;
06967 
06968         if(NC_indef(ncp))
06969                 return NC_EINDEFINE;
06970 
06971         varp = NC_lookupvar(ncp, varid);
06972         if(varp == NULL)
06973                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06974 
06975         if(varp->type == NC_CHAR)
06976                 return NC_ECHAR;
06977 
06978         if(varp->ndims == 0) /* scalar variable */
06979         {
06980                 const size_t zed = 0;
06981                 return( putNCv_short(ncp, varp, &zed, 1, value) );
06982         }
06983 
06984         if(!IS_RECVAR(varp))
06985         {
06986                 return(putNCv_short(ncp, varp, coord_zero, *varp->dsizes, value));
06987         }
06988         /* else */
06989 
06990         if(varp->ndims == 1
06991                         && ncp->recsize <= varp->len)
06992         {
06993                 /* one dimensional && the only record variable  */
06994                 return(putNCv_short(ncp, varp, coord_zero, NC_get_numrecs(ncp),
06995                         value));
06996         }
06997         /* else */
06998 
06999         {
07000         ALLOC_ONSTACK(coord, size_t, varp->ndims);
07001         size_t elemsPerRec = 1;
07002         const size_t nrecs = NC_get_numrecs(ncp);
07003         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
07004         /* TODO: fix dsizes to avoid this nonsense */
07005         if(varp->ndims > 1)
07006                 elemsPerRec = varp->dsizes[1];
07007         while(*coord < nrecs)
07008         {
07009                 const int lstatus = putNCv_short(ncp, varp, coord, elemsPerRec,
07010                                  value);
07011                 if(lstatus != NC_NOERR)
07012                 {
07013                         if(lstatus != NC_ERANGE)
07014                         {
07015                                 status = lstatus;
07016                                 /* fatal for the loop */
07017                                 break;
07018                         }
07019                         /* else NC_ERANGE, not fatal for the loop */
07020                         if(status == NC_NOERR)
07021                                 status = lstatus;
07022                 }
07023                 value += elemsPerRec;
07024                 (*coord)++;
07025         }
07026         FREE_ONSTACK(coord);
07027         } /* elemsPerRec */
07028 
07029         return status;
07030 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 6720 of file putget.c. References ALLOC_ONSTACK, coord_zero, NC_var::dsizes, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), NC_readonly, NC_var::ndims, putNCv_text(), NC::recsize, and NC_var::type. 
 06721 {
06722         int status = NC_NOERR;
06723         NC *ncp;
06724         const NC_var *varp;
06725 
06726         status = NC_check_id(ncid, &ncp); 
06727         if(status != NC_NOERR)
06728                 return status;
06729 
06730         if(NC_readonly(ncp))
06731                 return NC_EPERM;
06732 
06733         if(NC_indef(ncp))
06734                 return NC_EINDEFINE;
06735 
06736         varp = NC_lookupvar(ncp, varid);
06737         if(varp == NULL)
06738                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
06739 
06740         if(varp->type != NC_CHAR)
06741                 return NC_ECHAR;
06742 
06743         if(varp->ndims == 0) /* scalar variable */
06744         {
06745                 const size_t zed = 0;
06746                 return( putNCv_text(ncp, varp, &zed, 1, value) );
06747         }
06748 
06749         if(!IS_RECVAR(varp))
06750         {
06751                 return(putNCv_text(ncp, varp, coord_zero, *varp->dsizes, value));
06752         }
06753         /* else */
06754 
06755         if(varp->ndims == 1
06756                         && ncp->recsize <= varp->len)
06757         {
06758                 /* one dimensional && the only record variable  */
06759                 return(putNCv_text(ncp, varp, coord_zero, NC_get_numrecs(ncp),
06760                         value));
06761         }
06762         /* else */
06763 
06764         {
06765         ALLOC_ONSTACK(coord, size_t, varp->ndims);
06766         size_t elemsPerRec = 1;
06767         const size_t nrecs = NC_get_numrecs(ncp);
06768         (void) memset(coord, 0, varp->ndims * sizeof(size_t));
06769         /* TODO: fix dsizes to avoid this nonsense */
06770         if(varp->ndims > 1)
06771                 elemsPerRec = varp->dsizes[1];
06772         while(*coord < nrecs)
06773         {
06774                 const int lstatus = putNCv_text(ncp, varp, coord, elemsPerRec,
06775                                  value);
06776                 if(lstatus != NC_NOERR)
06777                 {
06778                         if(lstatus != NC_ERANGE)
06779                         {
06780                                 status = lstatus;
06781                                 /* fatal for the loop */
06782                                 break;
06783                         }
06784                         /* else NC_ERANGE, not fatal for the loop */
06785                         if(status == NC_NOERR)
06786                                 status = lstatus;
06787                 }
06788                 value += elemsPerRec;
06789                 (*coord)++;
06790         }
06791         FREE_ONSTACK(coord);
06792         } /* elemsPerRec */
06793 
06794         return status;
06795 }
 | 
| 
 | ||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5703 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_double(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_put_vara(), and nc_put_varm_double(). 
 05705 {
05706         int status = NC_NOERR;
05707         NC *ncp;
05708         const NC_var *varp;
05709         int ii;
05710         size_t iocount;
05711 
05712         status = NC_check_id(ncid, &ncp); 
05713         if(status != NC_NOERR)
05714                 return status;
05715 
05716         if(NC_readonly(ncp))
05717                 return NC_EPERM;
05718 
05719         if(NC_indef(ncp))
05720                 return NC_EINDEFINE;
05721 
05722         varp = NC_lookupvar(ncp, varid);
05723         if(varp == NULL)
05724                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05725 
05726         if(varp->type == NC_CHAR)
05727                 return NC_ECHAR;
05728 
05729         status = NCcoordck(ncp, varp, start);
05730         if(status != NC_NOERR)
05731                 return status;
05732         status = NCedgeck(ncp, varp, start, edges);
05733         if(status != NC_NOERR)
05734                 return status;
05735 
05736         if(varp->ndims == 0) /* scalar variable */
05737         {
05738                 return( putNCv_double(ncp, varp, start, 1, value) );
05739         }
05740 
05741         if(IS_RECVAR(varp))
05742         {
05743                 status = NCvnrecs(ncp, *start + *edges);
05744                 if(status != NC_NOERR)
05745                         return status;
05746 
05747                 if(varp->ndims == 1
05748                         && ncp->recsize <= varp->len)
05749                 {
05750                         /* one dimensional && the only record variable  */
05751                         return( putNCv_double(ncp, varp, start, *edges, value) );
05752                 }
05753         }
05754 
05755         /*
05756          * find max contiguous
05757          *   and accumulate max count for a single io operation
05758          */
05759         ii = NCiocount(ncp, varp, edges, &iocount);
05760 
05761         if(ii == -1)
05762         {
05763                 return( putNCv_double(ncp, varp, start, iocount, value) );
05764         }
05765 
05766         assert(ii >= 0);
05767 
05768 
05769         { /* inline */
05770         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05771         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05772         const size_t index = ii;
05773 
05774         /* copy in starting indices */
05775         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05776 
05777         /* set up in maximum indices */
05778         set_upper(upper, start, edges, &upper[varp->ndims]);
05779 
05780         /* ripple counter */
05781         while(*coord < *upper)
05782         {
05783                 const int lstatus = putNCv_double(ncp, varp, coord, iocount,
05784                                  value);
05785                 if(lstatus != NC_NOERR)
05786                 {
05787                         if(lstatus != NC_ERANGE)
05788                         {
05789                                 status = lstatus;
05790                                 /* fatal for the loop */
05791                                 break;
05792                         }
05793                         /* else NC_ERANGE, not fatal for the loop */
05794                         if(status == NC_NOERR)
05795                                 status = lstatus;
05796                 }
05797                 value += iocount;
05798                 odo1(start, upper, coord, &upper[index], &coord[index]);
05799         }
05800 
05801         FREE_ONSTACK(upper);
05802         FREE_ONSTACK(coord);
05803         } /* end inline */
05804 
05805         return status;
05806 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5597 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_float(), NC::recsize, set_upper(), and NC_var::type. Referenced by fill_seq(), nc_put_vara(), and nc_put_varm_float(). 
 05599 {
05600         int status = NC_NOERR;
05601         NC *ncp;
05602         const NC_var *varp;
05603         int ii;
05604         size_t iocount;
05605 
05606         status = NC_check_id(ncid, &ncp); 
05607         if(status != NC_NOERR)
05608                 return status;
05609 
05610         if(NC_readonly(ncp))
05611                 return NC_EPERM;
05612 
05613         if(NC_indef(ncp))
05614                 return NC_EINDEFINE;
05615 
05616         varp = NC_lookupvar(ncp, varid);
05617         if(varp == NULL)
05618                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05619 
05620         if(varp->type == NC_CHAR)
05621                 return NC_ECHAR;
05622 
05623         status = NCcoordck(ncp, varp, start);
05624         if(status != NC_NOERR)
05625                 return status;
05626         status = NCedgeck(ncp, varp, start, edges);
05627         if(status != NC_NOERR)
05628                 return status;
05629 
05630         if(varp->ndims == 0) /* scalar variable */
05631         {
05632                 return( putNCv_float(ncp, varp, start, 1, value) );
05633         }
05634 
05635         if(IS_RECVAR(varp))
05636         {
05637                 status = NCvnrecs(ncp, *start + *edges);
05638                 if(status != NC_NOERR)
05639                         return status;
05640 
05641                 if(varp->ndims == 1
05642                         && ncp->recsize <= varp->len)
05643                 {
05644                         /* one dimensional && the only record variable  */
05645                         return( putNCv_float(ncp, varp, start, *edges, value) );
05646                 }
05647         }
05648 
05649         /*
05650          * find max contiguous
05651          *   and accumulate max count for a single io operation
05652          */
05653         ii = NCiocount(ncp, varp, edges, &iocount);
05654 
05655         if(ii == -1)
05656         {
05657                 return( putNCv_float(ncp, varp, start, iocount, value) );
05658         }
05659 
05660         assert(ii >= 0);
05661 
05662 
05663         { /* inline */
05664         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05665         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05666         const size_t index = ii;
05667 
05668         /* copy in starting indices */
05669         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05670 
05671         /* set up in maximum indices */
05672         set_upper(upper, start, edges, &upper[varp->ndims]);
05673 
05674         /* ripple counter */
05675         while(*coord < *upper)
05676         {
05677                 const int lstatus = putNCv_float(ncp, varp, coord, iocount,
05678                                  value);
05679                 if(lstatus != NC_NOERR)
05680                 {
05681                         if(lstatus != NC_ERANGE)
05682                         {
05683                                 status = lstatus;
05684                                 /* fatal for the loop */
05685                                 break;
05686                         }
05687                         /* else NC_ERANGE, not fatal for the loop */
05688                         if(status == NC_NOERR)
05689                                 status = lstatus;
05690                 }
05691                 value += iocount;
05692                 odo1(start, upper, coord, &upper[index], &coord[index]);
05693         }
05694 
05695         FREE_ONSTACK(upper);
05696         FREE_ONSTACK(coord);
05697         } /* end inline */
05698 
05699         return status;
05700 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5385 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_int(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_put_vara(), and nc_put_varm_int(). 
 05387 {
05388         int status = NC_NOERR;
05389         NC *ncp;
05390         const NC_var *varp;
05391         int ii;
05392         size_t iocount;
05393 
05394         status = NC_check_id(ncid, &ncp); 
05395         if(status != NC_NOERR)
05396                 return status;
05397 
05398         if(NC_readonly(ncp))
05399                 return NC_EPERM;
05400 
05401         if(NC_indef(ncp))
05402                 return NC_EINDEFINE;
05403 
05404         varp = NC_lookupvar(ncp, varid);
05405         if(varp == NULL)
05406                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05407 
05408         if(varp->type == NC_CHAR)
05409                 return NC_ECHAR;
05410 
05411         status = NCcoordck(ncp, varp, start);
05412         if(status != NC_NOERR)
05413                 return status;
05414         status = NCedgeck(ncp, varp, start, edges);
05415         if(status != NC_NOERR)
05416                 return status;
05417 
05418         if(varp->ndims == 0) /* scalar variable */
05419         {
05420                 return( putNCv_int(ncp, varp, start, 1, value) );
05421         }
05422 
05423         if(IS_RECVAR(varp))
05424         {
05425                 status = NCvnrecs(ncp, *start + *edges);
05426                 if(status != NC_NOERR)
05427                         return status;
05428 
05429                 if(varp->ndims == 1
05430                         && ncp->recsize <= varp->len)
05431                 {
05432                         /* one dimensional && the only record variable  */
05433                         return( putNCv_int(ncp, varp, start, *edges, value) );
05434                 }
05435         }
05436 
05437         /*
05438          * find max contiguous
05439          *   and accumulate max count for a single io operation
05440          */
05441         ii = NCiocount(ncp, varp, edges, &iocount);
05442 
05443         if(ii == -1)
05444         {
05445                 return( putNCv_int(ncp, varp, start, iocount, value) );
05446         }
05447 
05448         assert(ii >= 0);
05449 
05450 
05451         { /* inline */
05452         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05453         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05454         const size_t index = ii;
05455 
05456         /* copy in starting indices */
05457         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05458 
05459         /* set up in maximum indices */
05460         set_upper(upper, start, edges, &upper[varp->ndims]);
05461 
05462         /* ripple counter */
05463         while(*coord < *upper)
05464         {
05465                 const int lstatus = putNCv_int(ncp, varp, coord, iocount,
05466                                  value);
05467                 if(lstatus != NC_NOERR)
05468                 {
05469                         if(lstatus != NC_ERANGE)
05470                         {
05471                                 status = lstatus;
05472                                 /* fatal for the loop */
05473                                 break;
05474                         }
05475                         /* else NC_ERANGE, not fatal for the loop */
05476                         if(status == NC_NOERR)
05477                                 status = lstatus;
05478                 }
05479                 value += iocount;
05480                 odo1(start, upper, coord, &upper[index], &coord[index]);
05481         }
05482 
05483         FREE_ONSTACK(upper);
05484         FREE_ONSTACK(coord);
05485         } /* end inline */
05486 
05487         return status;
05488 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5491 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_long(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_put_varm_long(). 
 05493 {
05494         int status = NC_NOERR;
05495         NC *ncp;
05496         const NC_var *varp;
05497         int ii;
05498         size_t iocount;
05499 
05500         status = NC_check_id(ncid, &ncp); 
05501         if(status != NC_NOERR)
05502                 return status;
05503 
05504         if(NC_readonly(ncp))
05505                 return NC_EPERM;
05506 
05507         if(NC_indef(ncp))
05508                 return NC_EINDEFINE;
05509 
05510         varp = NC_lookupvar(ncp, varid);
05511         if(varp == NULL)
05512                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05513 
05514         if(varp->type == NC_CHAR)
05515                 return NC_ECHAR;
05516 
05517         status = NCcoordck(ncp, varp, start);
05518         if(status != NC_NOERR)
05519                 return status;
05520         status = NCedgeck(ncp, varp, start, edges);
05521         if(status != NC_NOERR)
05522                 return status;
05523 
05524         if(varp->ndims == 0) /* scalar variable */
05525         {
05526                 return( putNCv_long(ncp, varp, start, 1, value) );
05527         }
05528 
05529         if(IS_RECVAR(varp))
05530         {
05531                 status = NCvnrecs(ncp, *start + *edges);
05532                 if(status != NC_NOERR)
05533                         return status;
05534 
05535                 if(varp->ndims == 1
05536                         && ncp->recsize <= varp->len)
05537                 {
05538                         /* one dimensional && the only record variable  */
05539                         return( putNCv_long(ncp, varp, start, *edges, value) );
05540                 }
05541         }
05542 
05543         /*
05544          * find max contiguous
05545          *   and accumulate max count for a single io operation
05546          */
05547         ii = NCiocount(ncp, varp, edges, &iocount);
05548 
05549         if(ii == -1)
05550         {
05551                 return( putNCv_long(ncp, varp, start, iocount, value) );
05552         }
05553 
05554         assert(ii >= 0);
05555 
05556 
05557         { /* inline */
05558         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05559         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05560         const size_t index = ii;
05561 
05562         /* copy in starting indices */
05563         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05564 
05565         /* set up in maximum indices */
05566         set_upper(upper, start, edges, &upper[varp->ndims]);
05567 
05568         /* ripple counter */
05569         while(*coord < *upper)
05570         {
05571                 const int lstatus = putNCv_long(ncp, varp, coord, iocount,
05572                                  value);
05573                 if(lstatus != NC_NOERR)
05574                 {
05575                         if(lstatus != NC_ERANGE)
05576                         {
05577                                 status = lstatus;
05578                                 /* fatal for the loop */
05579                                 break;
05580                         }
05581                         /* else NC_ERANGE, not fatal for the loop */
05582                         if(status == NC_NOERR)
05583                                 status = lstatus;
05584                 }
05585                 value += iocount;
05586                 odo1(start, upper, coord, &upper[index], &coord[index]);
05587         }
05588 
05589         FREE_ONSTACK(upper);
05590         FREE_ONSTACK(coord);
05591         } /* end inline */
05592 
05593         return status;
05594 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Referenced by main(), nc_put_vara(), and nc_put_varm_schar(). | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 5279 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_short(), NC::recsize, set_upper(), and NC_var::type. Referenced by nc_put_vara(), and nc_put_varm_short(). 
 05281 {
05282         int status = NC_NOERR;
05283         NC *ncp;
05284         const NC_var *varp;
05285         int ii;
05286         size_t iocount;
05287 
05288         status = NC_check_id(ncid, &ncp); 
05289         if(status != NC_NOERR)
05290                 return status;
05291 
05292         if(NC_readonly(ncp))
05293                 return NC_EPERM;
05294 
05295         if(NC_indef(ncp))
05296                 return NC_EINDEFINE;
05297 
05298         varp = NC_lookupvar(ncp, varid);
05299         if(varp == NULL)
05300                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
05301 
05302         if(varp->type == NC_CHAR)
05303                 return NC_ECHAR;
05304 
05305         status = NCcoordck(ncp, varp, start);
05306         if(status != NC_NOERR)
05307                 return status;
05308         status = NCedgeck(ncp, varp, start, edges);
05309         if(status != NC_NOERR)
05310                 return status;
05311 
05312         if(varp->ndims == 0) /* scalar variable */
05313         {
05314                 return( putNCv_short(ncp, varp, start, 1, value) );
05315         }
05316 
05317         if(IS_RECVAR(varp))
05318         {
05319                 status = NCvnrecs(ncp, *start + *edges);
05320                 if(status != NC_NOERR)
05321                         return status;
05322 
05323                 if(varp->ndims == 1
05324                         && ncp->recsize <= varp->len)
05325                 {
05326                         /* one dimensional && the only record variable  */
05327                         return( putNCv_short(ncp, varp, start, *edges, value) );
05328                 }
05329         }
05330 
05331         /*
05332          * find max contiguous
05333          *   and accumulate max count for a single io operation
05334          */
05335         ii = NCiocount(ncp, varp, edges, &iocount);
05336 
05337         if(ii == -1)
05338         {
05339                 return( putNCv_short(ncp, varp, start, iocount, value) );
05340         }
05341 
05342         assert(ii >= 0);
05343 
05344 
05345         { /* inline */
05346         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05347         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05348         const size_t index = ii;
05349 
05350         /* copy in starting indices */
05351         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05352 
05353         /* set up in maximum indices */
05354         set_upper(upper, start, edges, &upper[varp->ndims]);
05355 
05356         /* ripple counter */
05357         while(*coord < *upper)
05358         {
05359                 const int lstatus = putNCv_short(ncp, varp, coord, iocount,
05360                                  value);
05361                 if(lstatus != NC_NOERR)
05362                 {
05363                         if(lstatus != NC_ERANGE)
05364                         {
05365                                 status = lstatus;
05366                                 /* fatal for the loop */
05367                                 break;
05368                         }
05369                         /* else NC_ERANGE, not fatal for the loop */
05370                         if(status == NC_NOERR)
05371                                 status = lstatus;
05372                 }
05373                 value += iocount;
05374                 odo1(start, upper, coord, &upper[index], &coord[index]);
05375         }
05376 
05377         FREE_ONSTACK(upper);
05378         FREE_ONSTACK(coord);
05379         } /* end inline */
05380 
05381         return status;
05382 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 4960 of file putget.c. References ALLOC_ONSTACK, FREE_ONSTACK, IS_RECVAR, NC_var::len, NC_check_id(), NC_indef, NC_lookupvar(), NC_readonly, NCcoordck(), NCedgeck(), NCiocount(), NCvnrecs(), NC_var::ndims, odo1(), putNCv_text(), NC::recsize, set_upper(), and NC_var::type. Referenced by main(), nc_put_vara(), and nc_put_varm_text(). 
 04962 {
04963         int status = NC_NOERR;
04964         NC *ncp;
04965         const NC_var *varp;
04966         int ii;
04967         size_t iocount;
04968 
04969         status = NC_check_id(ncid, &ncp); 
04970         if(status != NC_NOERR)
04971                 return status;
04972 
04973         if(NC_readonly(ncp))
04974                 return NC_EPERM;
04975 
04976         if(NC_indef(ncp))
04977                 return NC_EINDEFINE;
04978 
04979         varp = NC_lookupvar(ncp, varid);
04980         if(varp == NULL)
04981                 return NC_ENOTVAR; /* TODO: lost NC_EGLOBAL */
04982 
04983         if(varp->type != NC_CHAR)
04984                 return NC_ECHAR;
04985 
04986         status = NCcoordck(ncp, varp, start);
04987         if(status != NC_NOERR)
04988                 return status;
04989         status = NCedgeck(ncp, varp, start, edges);
04990         if(status != NC_NOERR)
04991                 return status;
04992 
04993         if(varp->ndims == 0) /* scalar variable */
04994         {
04995                 return( putNCv_text(ncp, varp, start, 1, value) );
04996         }
04997 
04998         if(IS_RECVAR(varp))
04999         {
05000                 status = NCvnrecs(ncp, *start + *edges);
05001                 if(status != NC_NOERR)
05002                         return status;
05003 
05004                 if(varp->ndims == 1
05005                         && ncp->recsize <= varp->len)
05006                 {
05007                         /* one dimensional && the only record variable  */
05008                         return( putNCv_text(ncp, varp, start, *edges, value) );
05009                 }
05010         }
05011 
05012         /*
05013          * find max contiguous
05014          *   and accumulate max count for a single io operation
05015          */
05016         ii = NCiocount(ncp, varp, edges, &iocount);
05017 
05018         if(ii == -1)
05019         {
05020                 return( putNCv_text(ncp, varp, start, iocount, value) );
05021         }
05022 
05023         assert(ii >= 0);
05024 
05025 
05026         { /* inline */
05027         ALLOC_ONSTACK(coord, size_t, varp->ndims);
05028         ALLOC_ONSTACK(upper, size_t, varp->ndims);
05029         const size_t index = ii;
05030 
05031         /* copy in starting indices */
05032         (void) memcpy(coord, start, varp->ndims * sizeof(size_t));
05033 
05034         /* set up in maximum indices */
05035         set_upper(upper, start, edges, &upper[varp->ndims]);
05036 
05037         /* ripple counter */
05038         while(*coord < *upper)
05039         {
05040                 const int lstatus = putNCv_text(ncp, varp, coord, iocount,
05041                                  value);
05042                 if(lstatus != NC_NOERR)
05043                 {
05044                         if(lstatus != NC_ERANGE)
05045                         {
05046                                 status = lstatus;
05047                                 /* fatal for the loop */
05048                                 break;
05049                         }
05050                         /* else NC_ERANGE, not fatal for the loop */
05051                         if(status == NC_NOERR)
05052                                 status = lstatus;
05053                 }
05054                 value += iocount;
05055                 odo1(start, upper, coord, &upper[index], &coord[index]);
05056         }
05057 
05058         FREE_ONSTACK(upper);
05059         FREE_ONSTACK(coord);
05060         } /* end inline */
05061 
05062         return status;
05063 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Referenced by nc_put_varm_uchar(). | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 11083 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_double(), NC_readonly, NC_var::ndims, putNCv_double(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_double(). 
 11087 {
11088         int status = ENOERR;
11089         NC *ncp;
11090         NC_var *varp;
11091         int maxidim;    /* maximum dimensional index */
11092 
11093         status = NC_check_id (ncid, &ncp);
11094         if (status != NC_NOERR)
11095                 return status;
11096 
11097         if (NC_indef (ncp))
11098         {
11099                 return NC_EINDEFINE;
11100         }
11101 
11102                 if (NC_readonly (ncp))
11103                         return NC_EPERM;
11104         varp = NC_lookupvar (ncp, varid);
11105         if (varp == NULL)
11106                 return NC_ENOTVAR;
11107 
11108         if(varp->type == NC_CHAR)
11109                 return NC_ECHAR;
11110 
11111         maxidim = (int) varp->ndims - 1;
11112 
11113         if (maxidim < 0)
11114         {
11115                 /*
11116                  * The variable is a scalar; consequently,
11117                  * there s only one thing to get and only one place to put it.
11118                  * (Why was I called?)
11119                  */
11120                 return putNCv_double (ncp, varp, start, 1, value);
11121         }
11122         
11123         /*
11124          * else
11125          * The variable is an array.
11126          */
11127         {
11128                 int idim;
11129                 size_t *mystart = NULL;
11130                 size_t *myedges;
11131                 size_t *iocount;        /* count vector */
11132                 size_t *stop;   /* stop indexes */
11133                 size_t *length; /* edge lengths in bytes */
11134                 ptrdiff_t *mystride;
11135                 ptrdiff_t *mymap;
11136 
11137                 /*
11138                  * Verify stride argument.
11139                  */
11140                 for (idim = 0; idim <= maxidim; ++idim)
11141                 {
11142                         if (stride != NULL
11143                                 && (stride[idim] == 0
11144                 /* cast needed for braindead systems with signed size_t */
11145                                 || (unsigned long) stride[idim] >= X_INT_MAX))
11146                         {
11147                                 return NC_ESTRIDE;
11148                         }
11149                 }
11150 
11151                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
11152                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
11153                 if(mystart == NULL)
11154                         return NC_ENOMEM;
11155                 myedges = mystart + varp->ndims;
11156                 iocount = myedges + varp->ndims;
11157                 stop = iocount + varp->ndims;
11158                 length = stop + varp->ndims;
11159                 mystride = (ptrdiff_t *)(length + varp->ndims);
11160                 mymap = mystride + varp->ndims;
11161 
11162                 /*
11163                  * Initialize I/O parameters.
11164                  */
11165                 for (idim = maxidim; idim >= 0; --idim)
11166                 {
11167                         mystart[idim] = start != NULL
11168                                 ? start[idim]
11169                                 : 0;
11170 
11171                         if (edges[idim] == 0)
11172                         {
11173                                 status = NC_NOERR;      /* read/write no data */
11174                                 goto done;
11175                         }
11176 
11177                         myedges[idim] = edges != NULL
11178                                 ? edges[idim]
11179                                 : idim == 0 && IS_RECVAR (varp)
11180                                 ? NC_get_numrecs(ncp) - mystart[idim]
11181                                 : varp->shape[idim] - mystart[idim];
11182                         mystride[idim] = stride != NULL
11183                                 ? stride[idim]
11184                                 : 1;
11185                         mymap[idim] = map != NULL
11186                                 ? map[idim]
11187                                 : idim == maxidim
11188                                 ? 1
11189                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
11190 
11191                         iocount[idim] = 1;
11192                         length[idim] = mymap[idim] * myedges[idim];
11193                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
11194                 }
11195 
11196                 /*
11197                  * Check start, edges
11198                  */
11199                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
11200                 {
11201                         if (mystart[idim] >= varp->shape[idim])
11202                         {
11203                                 status = NC_EINVALCOORDS;
11204                                 goto done;
11205                         }
11206                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
11207                         {
11208                                 status = NC_EEDGE;
11209                                 goto done;
11210                         }
11211                 }
11212                 /*
11213                  * As an optimization, adjust I/O parameters when the fastest 
11214                  * dimension has unity stride both externally and internally.
11215                  * In this case, the user could have called a simpler routine
11216                  * (i.e. ncvarnc_put_vara_double()
11217                  */
11218                 if (mystride[maxidim] == 1
11219                         && mymap[maxidim] == 1)
11220                 {
11221                         iocount[maxidim] = myedges[maxidim];
11222                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
11223                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
11224                 }
11225 
11226                 /*
11227                  * Perform I/O.  Exit when done.
11228                  */
11229                 for (;;)
11230                 {
11231                         /* TODO: */
11232                         int lstatus = nc_put_vara_double (ncid, varid, mystart, iocount,
11233                                                 value);
11234                         if (lstatus != NC_NOERR 
11235                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
11236                                 status = lstatus;
11237 
11238                         /*
11239                          * The following code permutes through the variable s
11240                          * external start-index space and it s internal address
11241                          * space.  At the UPC, this algorithm is commonly
11242                          * called "odometer code".
11243                          */
11244                         idim = maxidim;
11245                 carry:
11246                         value += mymap[idim];
11247                         mystart[idim] += mystride[idim];
11248                         if (mystart[idim] == stop[idim])
11249                         {
11250                                 mystart[idim] = start[idim];
11251                                 value -= length[idim];
11252                                 if (--idim < 0)
11253                                         break; /* normal return */
11254                                 goto carry;
11255                         }
11256                 } /* I/O loop */
11257         done:
11258                 free(mystart);
11259         } /* variable is array */
11260         return status;
11261 
11262 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 10901 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_float(), NC_readonly, NC_var::ndims, putNCv_float(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_float(). 
 10905 {
10906         int status = ENOERR;
10907         NC *ncp;
10908         NC_var *varp;
10909         int maxidim;    /* maximum dimensional index */
10910 
10911         status = NC_check_id (ncid, &ncp);
10912         if (status != NC_NOERR)
10913                 return status;
10914 
10915         if (NC_indef (ncp))
10916         {
10917                 return NC_EINDEFINE;
10918         }
10919 
10920                 if (NC_readonly (ncp))
10921                         return NC_EPERM;
10922         varp = NC_lookupvar (ncp, varid);
10923         if (varp == NULL)
10924                 return NC_ENOTVAR;
10925 
10926         if(varp->type == NC_CHAR)
10927                 return NC_ECHAR;
10928 
10929         maxidim = (int) varp->ndims - 1;
10930 
10931         if (maxidim < 0)
10932         {
10933                 /*
10934                  * The variable is a scalar; consequently,
10935                  * there s only one thing to get and only one place to put it.
10936                  * (Why was I called?)
10937                  */
10938                 return putNCv_float (ncp, varp, start, 1, value);
10939         }
10940         
10941         /*
10942          * else
10943          * The variable is an array.
10944          */
10945         {
10946                 int idim;
10947                 size_t *mystart = NULL;
10948                 size_t *myedges;
10949                 size_t *iocount;        /* count vector */
10950                 size_t *stop;   /* stop indexes */
10951                 size_t *length; /* edge lengths in bytes */
10952                 ptrdiff_t *mystride;
10953                 ptrdiff_t *mymap;
10954 
10955                 /*
10956                  * Verify stride argument.
10957                  */
10958                 for (idim = 0; idim <= maxidim; ++idim)
10959                 {
10960                         if (stride != NULL
10961                                 && (stride[idim] == 0
10962                 /* cast needed for braindead systems with signed size_t */
10963                                 || (unsigned long) stride[idim] >= X_INT_MAX))
10964                         {
10965                                 return NC_ESTRIDE;
10966                         }
10967                 }
10968 
10969                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
10970                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
10971                 if(mystart == NULL)
10972                         return NC_ENOMEM;
10973                 myedges = mystart + varp->ndims;
10974                 iocount = myedges + varp->ndims;
10975                 stop = iocount + varp->ndims;
10976                 length = stop + varp->ndims;
10977                 mystride = (ptrdiff_t *)(length + varp->ndims);
10978                 mymap = mystride + varp->ndims;
10979 
10980                 /*
10981                  * Initialize I/O parameters.
10982                  */
10983                 for (idim = maxidim; idim >= 0; --idim)
10984                 {
10985                         mystart[idim] = start != NULL
10986                                 ? start[idim]
10987                                 : 0;
10988 
10989                         if (edges[idim] == 0)
10990                         {
10991                                 status = NC_NOERR;      /* read/write no data */
10992                                 goto done;
10993                         }
10994 
10995                         myedges[idim] = edges != NULL
10996                                 ? edges[idim]
10997                                 : idim == 0 && IS_RECVAR (varp)
10998                                 ? NC_get_numrecs(ncp) - mystart[idim]
10999                                 : varp->shape[idim] - mystart[idim];
11000                         mystride[idim] = stride != NULL
11001                                 ? stride[idim]
11002                                 : 1;
11003                         mymap[idim] = map != NULL
11004                                 ? map[idim]
11005                                 : idim == maxidim
11006                                 ? 1
11007                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
11008 
11009                         iocount[idim] = 1;
11010                         length[idim] = mymap[idim] * myedges[idim];
11011                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
11012                 }
11013 
11014                 /*
11015                  * Check start, edges
11016                  */
11017                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
11018                 {
11019                         if (mystart[idim] >= varp->shape[idim])
11020                         {
11021                                 status = NC_EINVALCOORDS;
11022                                 goto done;
11023                         }
11024                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
11025                         {
11026                                 status = NC_EEDGE;
11027                                 goto done;
11028                         }
11029                 }
11030                 /*
11031                  * As an optimization, adjust I/O parameters when the fastest 
11032                  * dimension has unity stride both externally and internally.
11033                  * In this case, the user could have called a simpler routine
11034                  * (i.e. ncvarnc_put_vara_float()
11035                  */
11036                 if (mystride[maxidim] == 1
11037                         && mymap[maxidim] == 1)
11038                 {
11039                         iocount[maxidim] = myedges[maxidim];
11040                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
11041                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
11042                 }
11043 
11044                 /*
11045                  * Perform I/O.  Exit when done.
11046                  */
11047                 for (;;)
11048                 {
11049                         /* TODO: */
11050                         int lstatus = nc_put_vara_float (ncid, varid, mystart, iocount,
11051                                                 value);
11052                         if (lstatus != NC_NOERR 
11053                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
11054                                 status = lstatus;
11055 
11056                         /*
11057                          * The following code permutes through the variable s
11058                          * external start-index space and it s internal address
11059                          * space.  At the UPC, this algorithm is commonly
11060                          * called "odometer code".
11061                          */
11062                         idim = maxidim;
11063                 carry:
11064                         value += mymap[idim];
11065                         mystart[idim] += mystride[idim];
11066                         if (mystart[idim] == stop[idim])
11067                         {
11068                                 mystart[idim] = start[idim];
11069                                 value -= length[idim];
11070                                 if (--idim < 0)
11071                                         break; /* normal return */
11072                                 goto carry;
11073                         }
11074                 } /* I/O loop */
11075         done:
11076                 free(mystart);
11077         } /* variable is array */
11078         return status;
11079 
11080 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 10537 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_int(), NC_readonly, NC_var::ndims, putNCv_int(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_int(). 
 10541 {
10542         int status = ENOERR;
10543         NC *ncp;
10544         NC_var *varp;
10545         int maxidim;    /* maximum dimensional index */
10546 
10547         status = NC_check_id (ncid, &ncp);
10548         if (status != NC_NOERR)
10549                 return status;
10550 
10551         if (NC_indef (ncp))
10552         {
10553                 return NC_EINDEFINE;
10554         }
10555 
10556                 if (NC_readonly (ncp))
10557                         return NC_EPERM;
10558         varp = NC_lookupvar (ncp, varid);
10559         if (varp == NULL)
10560                 return NC_ENOTVAR;
10561 
10562         if(varp->type == NC_CHAR)
10563                 return NC_ECHAR;
10564 
10565         maxidim = (int) varp->ndims - 1;
10566 
10567         if (maxidim < 0)
10568         {
10569                 /*
10570                  * The variable is a scalar; consequently,
10571                  * there s only one thing to get and only one place to put it.
10572                  * (Why was I called?)
10573                  */
10574                 return putNCv_int (ncp, varp, start, 1, value);
10575         }
10576         
10577         /*
10578          * else
10579          * The variable is an array.
10580          */
10581         {
10582                 int idim;
10583                 size_t *mystart = NULL;
10584                 size_t *myedges;
10585                 size_t *iocount;        /* count vector */
10586                 size_t *stop;   /* stop indexes */
10587                 size_t *length; /* edge lengths in bytes */
10588                 ptrdiff_t *mystride;
10589                 ptrdiff_t *mymap;
10590 
10591                 /*
10592                  * Verify stride argument.
10593                  */
10594                 for (idim = 0; idim <= maxidim; ++idim)
10595                 {
10596                         if (stride != NULL
10597                                 && (stride[idim] == 0
10598                 /* cast needed for braindead systems with signed size_t */
10599                                 || (unsigned long) stride[idim] >= X_INT_MAX))
10600                         {
10601                                 return NC_ESTRIDE;
10602                         }
10603                 }
10604 
10605                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
10606                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
10607                 if(mystart == NULL)
10608                         return NC_ENOMEM;
10609                 myedges = mystart + varp->ndims;
10610                 iocount = myedges + varp->ndims;
10611                 stop = iocount + varp->ndims;
10612                 length = stop + varp->ndims;
10613                 mystride = (ptrdiff_t *)(length + varp->ndims);
10614                 mymap = mystride + varp->ndims;
10615 
10616                 /*
10617                  * Initialize I/O parameters.
10618                  */
10619                 for (idim = maxidim; idim >= 0; --idim)
10620                 {
10621                         mystart[idim] = start != NULL
10622                                 ? start[idim]
10623                                 : 0;
10624 
10625                         if (edges[idim] == 0)
10626                         {
10627                                 status = NC_NOERR;      /* read/write no data */
10628                                 goto done;
10629                         }
10630 
10631                         myedges[idim] = edges != NULL
10632                                 ? edges[idim]
10633                                 : idim == 0 && IS_RECVAR (varp)
10634                                 ? NC_get_numrecs(ncp) - mystart[idim]
10635                                 : varp->shape[idim] - mystart[idim];
10636                         mystride[idim] = stride != NULL
10637                                 ? stride[idim]
10638                                 : 1;
10639                         mymap[idim] = map != NULL
10640                                 ? map[idim]
10641                                 : idim == maxidim
10642                                 ? 1
10643                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
10644 
10645                         iocount[idim] = 1;
10646                         length[idim] = mymap[idim] * myedges[idim];
10647                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
10648                 }
10649 
10650                 /*
10651                  * Check start, edges
10652                  */
10653                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
10654                 {
10655                         if (mystart[idim] >= varp->shape[idim])
10656                         {
10657                                 status = NC_EINVALCOORDS;
10658                                 goto done;
10659                         }
10660                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
10661                         {
10662                                 status = NC_EEDGE;
10663                                 goto done;
10664                         }
10665                 }
10666                 /*
10667                  * As an optimization, adjust I/O parameters when the fastest 
10668                  * dimension has unity stride both externally and internally.
10669                  * In this case, the user could have called a simpler routine
10670                  * (i.e. ncvarnc_put_vara_int()
10671                  */
10672                 if (mystride[maxidim] == 1
10673                         && mymap[maxidim] == 1)
10674                 {
10675                         iocount[maxidim] = myedges[maxidim];
10676                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
10677                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
10678                 }
10679 
10680                 /*
10681                  * Perform I/O.  Exit when done.
10682                  */
10683                 for (;;)
10684                 {
10685                         /* TODO: */
10686                         int lstatus = nc_put_vara_int (ncid, varid, mystart, iocount,
10687                                                 value);
10688                         if (lstatus != NC_NOERR 
10689                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
10690                                 status = lstatus;
10691 
10692                         /*
10693                          * The following code permutes through the variable s
10694                          * external start-index space and it s internal address
10695                          * space.  At the UPC, this algorithm is commonly
10696                          * called "odometer code".
10697                          */
10698                         idim = maxidim;
10699                 carry:
10700                         value += mymap[idim];
10701                         mystart[idim] += mystride[idim];
10702                         if (mystart[idim] == stop[idim])
10703                         {
10704                                 mystart[idim] = start[idim];
10705                                 value -= length[idim];
10706                                 if (--idim < 0)
10707                                         break; /* normal return */
10708                                 goto carry;
10709                         }
10710                 } /* I/O loop */
10711         done:
10712                 free(mystart);
10713         } /* variable is array */
10714         return status;
10715 
10716 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 10719 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_long(), NC_readonly, NC_var::ndims, putNCv_long(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_long(). 
 10723 {
10724         int status = ENOERR;
10725         NC *ncp;
10726         NC_var *varp;
10727         int maxidim;    /* maximum dimensional index */
10728 
10729         status = NC_check_id (ncid, &ncp);
10730         if (status != NC_NOERR)
10731                 return status;
10732 
10733         if (NC_indef (ncp))
10734         {
10735                 return NC_EINDEFINE;
10736         }
10737 
10738                 if (NC_readonly (ncp))
10739                         return NC_EPERM;
10740         varp = NC_lookupvar (ncp, varid);
10741         if (varp == NULL)
10742                 return NC_ENOTVAR;
10743 
10744         if(varp->type == NC_CHAR)
10745                 return NC_ECHAR;
10746 
10747         maxidim = (int) varp->ndims - 1;
10748 
10749         if (maxidim < 0)
10750         {
10751                 /*
10752                  * The variable is a scalar; consequently,
10753                  * there s only one thing to get and only one place to put it.
10754                  * (Why was I called?)
10755                  */
10756                 return putNCv_long (ncp, varp, start, 1, value);
10757         }
10758         
10759         /*
10760          * else
10761          * The variable is an array.
10762          */
10763         {
10764                 int idim;
10765                 size_t *mystart = NULL;
10766                 size_t *myedges;
10767                 size_t *iocount;        /* count vector */
10768                 size_t *stop;   /* stop indexes */
10769                 size_t *length; /* edge lengths in bytes */
10770                 ptrdiff_t *mystride;
10771                 ptrdiff_t *mymap;
10772 
10773                 /*
10774                  * Verify stride argument.
10775                  */
10776                 for (idim = 0; idim <= maxidim; ++idim)
10777                 {
10778                         if (stride != NULL
10779                                 && (stride[idim] == 0
10780                 /* cast needed for braindead systems with signed size_t */
10781                                 || (unsigned long) stride[idim] >= X_INT_MAX))
10782                         {
10783                                 return NC_ESTRIDE;
10784                         }
10785                 }
10786 
10787                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
10788                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
10789                 if(mystart == NULL)
10790                         return NC_ENOMEM;
10791                 myedges = mystart + varp->ndims;
10792                 iocount = myedges + varp->ndims;
10793                 stop = iocount + varp->ndims;
10794                 length = stop + varp->ndims;
10795                 mystride = (ptrdiff_t *)(length + varp->ndims);
10796                 mymap = mystride + varp->ndims;
10797 
10798                 /*
10799                  * Initialize I/O parameters.
10800                  */
10801                 for (idim = maxidim; idim >= 0; --idim)
10802                 {
10803                         mystart[idim] = start != NULL
10804                                 ? start[idim]
10805                                 : 0;
10806 
10807                         if (edges[idim] == 0)
10808                         {
10809                                 status = NC_NOERR;      /* read/write no data */
10810                                 goto done;
10811                         }
10812 
10813                         myedges[idim] = edges != NULL
10814                                 ? edges[idim]
10815                                 : idim == 0 && IS_RECVAR (varp)
10816                                 ? NC_get_numrecs(ncp) - mystart[idim]
10817                                 : varp->shape[idim] - mystart[idim];
10818                         mystride[idim] = stride != NULL
10819                                 ? stride[idim]
10820                                 : 1;
10821                         mymap[idim] = map != NULL
10822                                 ? map[idim]
10823                                 : idim == maxidim
10824                                 ? 1
10825                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
10826 
10827                         iocount[idim] = 1;
10828                         length[idim] = mymap[idim] * myedges[idim];
10829                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
10830                 }
10831 
10832                 /*
10833                  * Check start, edges
10834                  */
10835                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
10836                 {
10837                         if (mystart[idim] >= varp->shape[idim])
10838                         {
10839                                 status = NC_EINVALCOORDS;
10840                                 goto done;
10841                         }
10842                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
10843                         {
10844                                 status = NC_EEDGE;
10845                                 goto done;
10846                         }
10847                 }
10848                 /*
10849                  * As an optimization, adjust I/O parameters when the fastest 
10850                  * dimension has unity stride both externally and internally.
10851                  * In this case, the user could have called a simpler routine
10852                  * (i.e. ncvarnc_put_vara_long()
10853                  */
10854                 if (mystride[maxidim] == 1
10855                         && mymap[maxidim] == 1)
10856                 {
10857                         iocount[maxidim] = myedges[maxidim];
10858                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
10859                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
10860                 }
10861 
10862                 /*
10863                  * Perform I/O.  Exit when done.
10864                  */
10865                 for (;;)
10866                 {
10867                         /* TODO: */
10868                         int lstatus = nc_put_vara_long (ncid, varid, mystart, iocount,
10869                                                 value);
10870                         if (lstatus != NC_NOERR 
10871                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
10872                                 status = lstatus;
10873 
10874                         /*
10875                          * The following code permutes through the variable s
10876                          * external start-index space and it s internal address
10877                          * space.  At the UPC, this algorithm is commonly
10878                          * called "odometer code".
10879                          */
10880                         idim = maxidim;
10881                 carry:
10882                         value += mymap[idim];
10883                         mystart[idim] += mystride[idim];
10884                         if (mystart[idim] == stop[idim])
10885                         {
10886                                 mystart[idim] = start[idim];
10887                                 value -= length[idim];
10888                                 if (--idim < 0)
10889                                         break; /* normal return */
10890                                 goto carry;
10891                         }
10892                 } /* I/O loop */
10893         done:
10894                 free(mystart);
10895         } /* variable is array */
10896         return status;
10897 
10898 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Referenced by nc_put_varm(), and nc_put_vars_schar(). | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 10355 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_short(), NC_readonly, NC_var::ndims, putNCv_short(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_short(). 
 10359 {
10360         int status = ENOERR;
10361         NC *ncp;
10362         NC_var *varp;
10363         int maxidim;    /* maximum dimensional index */
10364 
10365         status = NC_check_id (ncid, &ncp);
10366         if (status != NC_NOERR)
10367                 return status;
10368 
10369         if (NC_indef (ncp))
10370         {
10371                 return NC_EINDEFINE;
10372         }
10373 
10374                 if (NC_readonly (ncp))
10375                         return NC_EPERM;
10376         varp = NC_lookupvar (ncp, varid);
10377         if (varp == NULL)
10378                 return NC_ENOTVAR;
10379 
10380         if(varp->type == NC_CHAR)
10381                 return NC_ECHAR;
10382 
10383         maxidim = (int) varp->ndims - 1;
10384 
10385         if (maxidim < 0)
10386         {
10387                 /*
10388                  * The variable is a scalar; consequently,
10389                  * there s only one thing to get and only one place to put it.
10390                  * (Why was I called?)
10391                  */
10392                 return putNCv_short (ncp, varp, start, 1, value);
10393         }
10394         
10395         /*
10396          * else
10397          * The variable is an array.
10398          */
10399         {
10400                 int idim;
10401                 size_t *mystart = NULL;
10402                 size_t *myedges;
10403                 size_t *iocount;        /* count vector */
10404                 size_t *stop;   /* stop indexes */
10405                 size_t *length; /* edge lengths in bytes */
10406                 ptrdiff_t *mystride;
10407                 ptrdiff_t *mymap;
10408 
10409                 /*
10410                  * Verify stride argument.
10411                  */
10412                 for (idim = 0; idim <= maxidim; ++idim)
10413                 {
10414                         if (stride != NULL
10415                                 && (stride[idim] == 0
10416                 /* cast needed for braindead systems with signed size_t */
10417                                 || (unsigned long) stride[idim] >= X_INT_MAX))
10418                         {
10419                                 return NC_ESTRIDE;
10420                         }
10421                 }
10422 
10423                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
10424                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
10425                 if(mystart == NULL)
10426                         return NC_ENOMEM;
10427                 myedges = mystart + varp->ndims;
10428                 iocount = myedges + varp->ndims;
10429                 stop = iocount + varp->ndims;
10430                 length = stop + varp->ndims;
10431                 mystride = (ptrdiff_t *)(length + varp->ndims);
10432                 mymap = mystride + varp->ndims;
10433 
10434                 /*
10435                  * Initialize I/O parameters.
10436                  */
10437                 for (idim = maxidim; idim >= 0; --idim)
10438                 {
10439                         mystart[idim] = start != NULL
10440                                 ? start[idim]
10441                                 : 0;
10442 
10443                         if (edges[idim] == 0)
10444                         {
10445                                 status = NC_NOERR;      /* read/write no data */
10446                                 goto done;
10447                         }
10448 
10449                         myedges[idim] = edges != NULL
10450                                 ? edges[idim]
10451                                 : idim == 0 && IS_RECVAR (varp)
10452                                 ? NC_get_numrecs(ncp) - mystart[idim]
10453                                 : varp->shape[idim] - mystart[idim];
10454                         mystride[idim] = stride != NULL
10455                                 ? stride[idim]
10456                                 : 1;
10457                         mymap[idim] = map != NULL
10458                                 ? map[idim]
10459                                 : idim == maxidim
10460                                 ? 1
10461                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
10462 
10463                         iocount[idim] = 1;
10464                         length[idim] = mymap[idim] * myedges[idim];
10465                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
10466                 }
10467 
10468                 /*
10469                  * Check start, edges
10470                  */
10471                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
10472                 {
10473                         if (mystart[idim] >= varp->shape[idim])
10474                         {
10475                                 status = NC_EINVALCOORDS;
10476                                 goto done;
10477                         }
10478                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
10479                         {
10480                                 status = NC_EEDGE;
10481                                 goto done;
10482                         }
10483                 }
10484                 /*
10485                  * As an optimization, adjust I/O parameters when the fastest 
10486                  * dimension has unity stride both externally and internally.
10487                  * In this case, the user could have called a simpler routine
10488                  * (i.e. ncvarnc_put_vara_short()
10489                  */
10490                 if (mystride[maxidim] == 1
10491                         && mymap[maxidim] == 1)
10492                 {
10493                         iocount[maxidim] = myedges[maxidim];
10494                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
10495                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
10496                 }
10497 
10498                 /*
10499                  * Perform I/O.  Exit when done.
10500                  */
10501                 for (;;)
10502                 {
10503                         /* TODO: */
10504                         int lstatus = nc_put_vara_short (ncid, varid, mystart, iocount,
10505                                                 value);
10506                         if (lstatus != NC_NOERR 
10507                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
10508                                 status = lstatus;
10509 
10510                         /*
10511                          * The following code permutes through the variable s
10512                          * external start-index space and it s internal address
10513                          * space.  At the UPC, this algorithm is commonly
10514                          * called "odometer code".
10515                          */
10516                         idim = maxidim;
10517                 carry:
10518                         value += mymap[idim];
10519                         mystart[idim] += mystride[idim];
10520                         if (mystart[idim] == stop[idim])
10521                         {
10522                                 mystart[idim] = start[idim];
10523                                 value -= length[idim];
10524                                 if (--idim < 0)
10525                                         break; /* normal return */
10526                                 goto carry;
10527                         }
10528                 } /* I/O loop */
10529         done:
10530                 free(mystart);
10531         } /* variable is array */
10532         return status;
10533 
10534 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 9808 of file putget.c. References calloc, free, IS_RECVAR, NC_check_id(), NC_get_numrecs, NC_indef, NC_lookupvar(), nc_put_vara_text(), NC_readonly, NC_var::ndims, putNCv_text(), NC_var::shape, stride, and NC_var::type. Referenced by nc_put_varm(), and nc_put_vars_text(). 
 09812 {
09813         int status = ENOERR;
09814         NC *ncp;
09815         NC_var *varp;
09816         int maxidim;    /* maximum dimensional index */
09817 
09818         status = NC_check_id (ncid, &ncp);
09819         if (status != NC_NOERR)
09820                 return status;
09821 
09822         if (NC_indef (ncp))
09823         {
09824                 return NC_EINDEFINE;
09825         }
09826 
09827                 if (NC_readonly (ncp))
09828                         return NC_EPERM;
09829         varp = NC_lookupvar (ncp, varid);
09830         if (varp == NULL)
09831                 return NC_ENOTVAR;
09832 
09833         if(varp->type != NC_CHAR)
09834                 return NC_ECHAR;
09835 
09836         maxidim = (int) varp->ndims - 1;
09837 
09838         if (maxidim < 0)
09839         {
09840                 /*
09841                  * The variable is a scalar; consequently,
09842                  * there s only one thing to get and only one place to put it.
09843                  * (Why was I called?)
09844                  */
09845                 return putNCv_text (ncp, varp, start, 1, value);
09846         }
09847         
09848         /*
09849          * else
09850          * The variable is an array.
09851          */
09852         {
09853                 int idim;
09854                 size_t *mystart = NULL;
09855                 size_t *myedges;
09856                 size_t *iocount;        /* count vector */
09857                 size_t *stop;   /* stop indexes */
09858                 size_t *length; /* edge lengths in bytes */
09859                 ptrdiff_t *mystride;
09860                 ptrdiff_t *mymap;
09861 
09862                 /*
09863                  * Verify stride argument.
09864                  */
09865                 for (idim = 0; idim <= maxidim; ++idim)
09866                 {
09867                         if (stride != NULL
09868                                 && (stride[idim] == 0
09869                 /* cast needed for braindead systems with signed size_t */
09870                                 || (unsigned long) stride[idim] >= X_INT_MAX))
09871                         {
09872                                 return NC_ESTRIDE;
09873                         }
09874                 }
09875 
09876                 /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */
09877                 mystart = (size_t *)calloc(varp->ndims * 7, sizeof(ptrdiff_t));
09878                 if(mystart == NULL)
09879                         return NC_ENOMEM;
09880                 myedges = mystart + varp->ndims;
09881                 iocount = myedges + varp->ndims;
09882                 stop = iocount + varp->ndims;
09883                 length = stop + varp->ndims;
09884                 mystride = (ptrdiff_t *)(length + varp->ndims);
09885                 mymap = mystride + varp->ndims;
09886 
09887                 /*
09888                  * Initialize I/O parameters.
09889                  */
09890                 for (idim = maxidim; idim >= 0; --idim)
09891                 {
09892                         mystart[idim] = start != NULL
09893                                 ? start[idim]
09894                                 : 0;
09895 
09896                         if (edges[idim] == 0)
09897                         {
09898                                 status = NC_NOERR;      /* read/write no data */
09899                                 goto done;
09900                         }
09901 
09902                         myedges[idim] = edges != NULL
09903                                 ? edges[idim]
09904                                 : idim == 0 && IS_RECVAR (varp)
09905                                 ? NC_get_numrecs(ncp) - mystart[idim]
09906                                 : varp->shape[idim] - mystart[idim];
09907                         mystride[idim] = stride != NULL
09908                                 ? stride[idim]
09909                                 : 1;
09910                         mymap[idim] = map != NULL
09911                                 ? map[idim]
09912                                 : idim == maxidim
09913                                 ? 1
09914                                 : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1];
09915 
09916                         iocount[idim] = 1;
09917                         length[idim] = mymap[idim] * myedges[idim];
09918                         stop[idim] = mystart[idim] + myedges[idim] * mystride[idim];
09919                 }
09920 
09921                 /*
09922                  * Check start, edges
09923                  */
09924                 for (idim = IS_RECVAR (varp); idim < maxidim; ++idim)
09925                 {
09926                         if (mystart[idim] >= varp->shape[idim])
09927                         {
09928                                 status = NC_EINVALCOORDS;
09929                                 goto done;
09930                         }
09931                         if (mystart[idim] + myedges[idim] > varp->shape[idim])
09932                         {
09933                                 status = NC_EEDGE;
09934                                 goto done;
09935                         }
09936                 }
09937                 /*
09938                  * As an optimization, adjust I/O parameters when the fastest 
09939                  * dimension has unity stride both externally and internally.
09940                  * In this case, the user could have called a simpler routine
09941                  * (i.e. ncvarnc_put_vara_text()
09942                  */
09943                 if (mystride[maxidim] == 1
09944                         && mymap[maxidim] == 1)
09945                 {
09946                         iocount[maxidim] = myedges[maxidim];
09947                         mystride[maxidim] = (ptrdiff_t) myedges[maxidim];
09948                         mymap[maxidim] = (ptrdiff_t) length[maxidim];
09949                 }
09950 
09951                 /*
09952                  * Perform I/O.  Exit when done.
09953                  */
09954                 for (;;)
09955                 {
09956                         /* TODO: */
09957                         int lstatus = nc_put_vara_text (ncid, varid, mystart, iocount,
09958                                                 value);
09959                         if (lstatus != NC_NOERR 
09960                                 && (status == NC_NOERR || lstatus != NC_ERANGE))
09961                                 status = lstatus;
09962 
09963                         /*
09964                          * The following code permutes through the variable s
09965                          * external start-index space and it s internal address
09966                          * space.  At the UPC, this algorithm is commonly
09967                          * called "odometer code".
09968                          */
09969                         idim = maxidim;
09970                 carry:
09971                         value += mymap[idim];
09972                         mystart[idim] += mystride[idim];
09973                         if (mystart[idim] == stop[idim])
09974                         {
09975                                 mystart[idim] = start[idim];
09976                                 value -= length[idim];
09977                                 if (--idim < 0)
09978                                         break; /* normal return */
09979                                 goto carry;
09980                         }
09981                 } /* I/O loop */
09982         done:
09983                 free(mystart);
09984         } /* variable is array */
09985         return status;
09986 
09987 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Referenced by nc_put_vars_uchar(). | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8176 of file putget.c. References nc_put_varm_double(), and stride. 
 08183 {
08184         return nc_put_varm_double (ncid, varid, start, edges,
08185                          stride, 0, value);
08186 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8163 of file putget.c. References nc_put_varm_float(), and stride. 
 08170 {
08171         return nc_put_varm_float (ncid, varid, start, edges,
08172                          stride, 0, value);
08173 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8137 of file putget.c. References nc_put_varm_int(), and stride. 
 08144 {
08145         return nc_put_varm_int (ncid, varid, start, edges,
08146                          stride, 0, value);
08147 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8150 of file putget.c. References nc_put_varm_long(), and stride. 
 08157 {
08158         return nc_put_varm_long (ncid, varid, start, edges,
08159                          stride, 0, value);
08160 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8124 of file putget.c. References nc_put_varm_short(), and stride. 
 08131 {
08132         return nc_put_varm_short (ncid, varid, start, edges,
08133                          stride, 0, value);
08134 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 8084 of file putget.c. References nc_put_varm_text(), and stride. 
 08091 {
08092         return nc_put_varm_text (ncid, varid, start, edges,
08093                          stride, 0, value);
08094 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 | 
| 
 | 
| 
 Definition at line 1081 of file nc.c. References dup_NC(), fIsSet, NC::flags, fSet, ncio::ioflags, NC_check_id(), NC_INDEF, NC_indef, NC_readonly, NC_sync(), NC::nciop, and NC::old. Referenced by main(), and ncredef(). 
 01082 {
01083         int status;
01084         NC *ncp;
01085 
01086         status = NC_check_id(ncid, &ncp); 
01087         if(status != NC_NOERR)
01088                 return status;
01089 
01090         if(NC_readonly(ncp))
01091                 return NC_EPERM;
01092 
01093         if(NC_indef(ncp))
01094                 return NC_EINDEFINE;
01095 
01096         
01097         if(fIsSet(ncp->nciop->ioflags, NC_SHARE))
01098         {
01099                 /* read in from disk */
01100                 status = NC_sync(ncp);
01101                 if(status != NC_NOERR)
01102                         return status;
01103         }
01104 
01105         ncp->old = dup_NC(ncp);
01106         if(ncp->old == NULL)
01107                 return NC_ENOMEM;
01108 
01109         fSet(ncp->flags, NC_INDEF);
01110 
01111         return NC_NOERR;
01112 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 489 of file attr.c. References free_NC_string(), NC_attr::name, name, NC_attrarray0(), NC_check_id(), NC_check_name(), NC_doHsync, NC_findattr(), NC_indef, NC_readonly, NC_sync(), new_NC_string(), set_NC_hdirty, and set_NC_string(). Referenced by main(), and ncattrename(). 
 00490 {
00491         int status;
00492         NC *ncp;
00493         NC_attrarray *ncap;
00494         NC_attr **tmp;
00495         NC_attr *attrp;
00496         NC_string *newStr, *old;
00497 
00498                         /* sortof inline clone of NC_lookupattr() */
00499         status = NC_check_id(ncid, &ncp);
00500         if(status != NC_NOERR)
00501                 return status;
00502 
00503         if(NC_readonly(ncp))
00504                 return NC_EPERM;
00505 
00506         ncap = NC_attrarray0(ncp, varid);
00507         if(ncap == NULL)
00508                 return NC_ENOTVAR;
00509 
00510         status = NC_check_name(name);
00511         if(status != NC_NOERR)
00512                 return status;
00513 
00514         tmp = NC_findattr(ncap, name);
00515         if(tmp == NULL)
00516                 return NC_ENOTATT;
00517         attrp = *tmp;
00518                         /* end inline clone NC_lookupattr() */
00519 
00520         if(NC_findattr(ncap, newname) != NULL)
00521         {
00522                 /* name in use */
00523                 return NC_ENAMEINUSE;
00524         }
00525 
00526         old = attrp->name;
00527         if(NC_indef(ncp))
00528         {
00529                 newStr = new_NC_string(strlen(newname), newname);
00530                 if( newStr == NULL)
00531                         return NC_ENOMEM;
00532                 attrp->name = newStr;
00533                 free_NC_string(old);
00534                 return NC_NOERR;
00535         }
00536         /* else */
00537         status = set_NC_string(old, newname);
00538         if( status != NC_NOERR)
00539                 return status;
00540 
00541         set_NC_hdirty(ncp);
00542 
00543         if(NC_doHsync(ncp))
00544         {
00545                 status = NC_sync(ncp);
00546                 if(status != NC_NOERR)
00547                         return status;
00548         }
00549 
00550         return NC_NOERR;
00551 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 466 of file dim.c. References NC::dims, elem_NC_dimarray(), free_NC_string(), NC_dim::name, NC_check_id(), NC_check_name(), NC_doHsync, NC_finddim(), NC_indef, NC_readonly, NC_sync(), new_NC_string(), set_NC_hdirty, and set_NC_string(). Referenced by main(), and ncdimrename(). 
 00467 {
00468         int status;
00469         NC *ncp;
00470         int existid;
00471         NC_dim *dimp;
00472 
00473         status = NC_check_id(ncid, &ncp); 
00474         if(status != NC_NOERR)
00475                 return status;
00476 
00477         if(NC_readonly(ncp))
00478                 return NC_EPERM;
00479 
00480         status = NC_check_name(newname);
00481         if(status != NC_NOERR)
00482                 return status;
00483 
00484         existid = NC_finddim(&ncp->dims, newname, &dimp);
00485         if(existid != -1)
00486                 return NC_ENAMEINUSE;
00487 
00488         dimp = elem_NC_dimarray(&ncp->dims, (size_t)dimid);
00489         if(dimp == NULL)
00490                 return NC_EBADDIM;
00491 
00492         if(NC_indef(ncp))
00493         {
00494                 NC_string *old = dimp->name;
00495                 NC_string *newStr = new_NC_string(strlen(newname), newname);
00496                 if(newStr == NULL)
00497                         return NC_ENOMEM;
00498                 dimp->name = newStr;
00499                 free_NC_string(old);
00500                 return NC_NOERR;
00501         }
00502 
00503         /* else, not in define mode */
00504 
00505         status = set_NC_string(dimp->name, newname);
00506         if(status != NC_NOERR)
00507                 return status;
00508 
00509         set_NC_hdirty(ncp);
00510 
00511         if(NC_doHsync(ncp))
00512         {
00513                 status = NC_sync(ncp);
00514                 if(status != NC_NOERR)
00515                         return status;
00516         }
00517 
00518         return NC_NOERR;
00519 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 723 of file var.c. References free_NC_string(), NC_var::name, NC_check_id(), NC_check_name(), NC_doHsync, NC_findvar(), NC_indef, NC_lookupvar(), NC_readonly, NC_sync(), new_NC_string(), set_NC_hdirty, set_NC_string(), and NC::vars. Referenced by ncvarrename(). 
 00724 {
00725         int status;
00726         NC *ncp;
00727         NC_var *varp;
00728         NC_string *old, *newStr;
00729         int other;
00730 
00731         status = NC_check_id(ncid, &ncp); 
00732         if(status != NC_NOERR)
00733                 return status;
00734 
00735         if(NC_readonly(ncp))
00736         {
00737                 return NC_EPERM;
00738         }
00739 
00740         status = NC_check_name(newname);
00741         if(status != NC_NOERR)
00742                 return status;
00743 
00744         /* check for name in use */
00745         other = NC_findvar(&ncp->vars, newname, &varp);
00746         if(other != -1)
00747         {
00748                 return NC_ENAMEINUSE;
00749         }
00750         
00751         varp = NC_lookupvar(ncp, varid);
00752         if(varp == NULL)
00753         {
00754                 /* invalid varid */
00755                 return NC_ENOTVAR; /* TODO: is this the right error code? */
00756         }
00757 
00758         old = varp->name;
00759         if(NC_indef(ncp))
00760         {
00761                 newStr = new_NC_string(strlen(newname),newname);
00762                 if(newStr == NULL)
00763                         return(-1);
00764                 varp->name = newStr;
00765                 free_NC_string(old);
00766                 return NC_NOERR;
00767         }
00768 
00769         /* else, not in define mode */
00770         status = set_NC_string(varp->name, newname);
00771         if(status != NC_NOERR)
00772                 return status;
00773 
00774         set_NC_hdirty(ncp);
00775 
00776         if(NC_doHsync(ncp))
00777         {
00778                 status = NC_sync(ncp);
00779                 if(status != NC_NOERR)
00780                         return status;
00781         }
00782 
00783         return NC_NOERR;
00784 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 1309 of file nc.c. References NC_check_id(), and NC_get_numrecs. 
 01310 {
01311 #if _CRAYMPP && defined(LOCKNUMREC)
01312         int status;
01313         NC *ncp;
01314         shmem_t numrecs;
01315 
01316         if ((status = NC_check_id(ncid, &ncp)) != NC_NOERR) {
01317                 return status;
01318         }
01319         if (pe < 0 || pe >= _num_pes()) {
01320                 return NC_EINVAL; /* invalid base pe */
01321         }
01322 
01323         numrecs = (shmem_t) NC_get_numrecs(ncp);
01324 
01325         ncp->lock[LOCKNUMREC_VALUE] = (ushmem_t) numrecs;
01326 
01327         /* update serving & lock values for a "smooth" transition */
01328         /* note that the "real" server will being doing this as well */
01329         /* as all the rest in the group */
01330         /* must have syncronization before & after this step */
01331         shmem_short_get(
01332                 (shmem_t *) ncp->lock + LOCKNUMREC_SERVING,
01333                 (shmem_t *) ncp->lock + LOCKNUMREC_SERVING,
01334                 1, ncp->lock[LOCKNUMREC_BASEPE]);
01335 
01336         shmem_short_get(
01337                 (shmem_t *) ncp->lock + LOCKNUMREC_LOCK,
01338                 (shmem_t *) ncp->lock + LOCKNUMREC_LOCK,
01339                 1, ncp->lock[LOCKNUMREC_BASEPE]);
01340 
01341         /* complete transition */
01342         ncp->lock[LOCKNUMREC_BASEPE] = (ushmem_t) pe;
01343 
01344 #endif /* _CRAYMPP && LOCKNUMREC */
01345         return NC_NOERR;
01346 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 1234 of file nc.c. References fClr, fIsSet, NC::flags, fSet, NC_check_id(), NC_readonly, and NC_sync(). Referenced by ncsetfill(). 
 01236 {
01237         int status;
01238         NC *ncp;
01239         int oldmode;
01240 
01241         status = NC_check_id(ncid, &ncp); 
01242         if(status != NC_NOERR)
01243                 return status;
01244 
01245         if(NC_readonly(ncp))
01246                 return NC_EPERM;
01247 
01248         oldmode = fIsSet(ncp->flags, NC_NOFILL) ? NC_NOFILL : NC_FILL;
01249 
01250         if(fillmode == NC_NOFILL)
01251         {
01252                 fSet(ncp->flags, NC_NOFILL);
01253         }
01254         else if(fillmode == NC_FILL)
01255         {
01256                 if(fIsSet(ncp->flags, NC_NOFILL))
01257                 {
01258                         /*
01259                          * We are changing back to fill mode
01260                          * so do a sync
01261                          */
01262                         status = NC_sync(ncp);
01263                         if(status != NC_NOERR)
01264                                 return status;
01265                 }
01266                 fClr(ncp->flags, NC_NOFILL);
01267         }
01268         else
01269         {
01270                 return NC_EINVAL; /* Invalid fillmode */
01271         }
01272 
01273         if(old_mode_ptr != NULL)
01274                 *old_mode_ptr = oldmode;
01275 
01276         return NC_NOERR;
01277 }
 | 
| 
 | 
| 
 Definition at line 74 of file netcdf-3.5.0/src/libsrc/error.c. References NC_ISSYSERR, strerror(), and unknown. Referenced by do_ncdump(), main(), and nc_advise(). 
 00075 {
00076 
00077 #ifdef vms 
00078         if(err == EVMSERR)
00079         {
00080                 return vms_strerror(err);
00081         }       
00082         /* else */
00083 #endif /* vms */
00084 
00085         if(NC_ISSYSERR(err))
00086         {
00087                 const char *cp = (const char *) strerror(err);
00088                 if(cp == NULL)
00089                         return unknown;
00090                 /* else */
00091                 return cp;
00092         }
00093         /* else */
00094 
00095         switch (err) {
00096         case NC_NOERR:
00097             return "No error";
00098         case NC_EBADID:
00099             return "Not a netCDF id";
00100         case NC_ENFILE:
00101             return "Too many netCDF files open";
00102         case NC_EEXIST:
00103             return "netCDF file exists && NC_NOCLOBBER";
00104         case NC_EINVAL:
00105             return "Invalid argument";
00106         case NC_EPERM:
00107             return "Write to read only";
00108         case NC_ENOTINDEFINE:
00109             return "Operation not allowed in data mode";
00110         case NC_EINDEFINE:
00111             return "Operation not allowed in define mode";
00112         case NC_EINVALCOORDS:
00113             return "Index exceeds dimension bound";
00114         case NC_EMAXDIMS:
00115             return "NC_MAX_DIMS exceeded";
00116         case NC_ENAMEINUSE:
00117             return "String match to name in use";
00118         case NC_ENOTATT:
00119             return "Attribute not found";
00120         case NC_EMAXATTS:
00121             return "NC_MAX_ATTRS exceeded";
00122         case NC_EBADTYPE:
00123             return "Not a netCDF data type or _FillValue type mismatch";
00124         case NC_EBADDIM:
00125             return "Invalid dimension id or name";
00126         case NC_EUNLIMPOS:
00127             return "NC_UNLIMITED in the wrong index";
00128         case NC_EMAXVARS:
00129             return "NC_MAX_VARS exceeded";
00130         case NC_ENOTVAR:
00131             return "Variable not found";
00132         case NC_EGLOBAL:
00133             return "Action prohibited on NC_GLOBAL varid";
00134         case NC_ENOTNC:
00135             return "Not a netCDF file";
00136         case NC_ESTS:
00137             return "In Fortran, string too short";
00138         case NC_EMAXNAME:
00139             return "NC_MAX_NAME exceeded";
00140         case NC_EUNLIMIT:
00141             return "NC_UNLIMITED size already in use";
00142         case NC_ENORECVARS:
00143             return "nc_rec op when there are no record vars";
00144         case NC_ECHAR:
00145             return "Attempt to convert between text & numbers";
00146         case NC_EEDGE:
00147             return "Edge+start exceeds dimension bound";
00148         case NC_ESTRIDE:
00149             return "Illegal stride";
00150         case NC_EBADNAME:
00151             return "Attribute or variable name contains illegal characters";
00152         case NC_ERANGE:
00153             return "Numeric conversion not representable";
00154         case NC_ENOMEM:
00155             return "Memory allocation (malloc) failure";
00156         }
00157         /* default */
00158         return unknown;
00159 }
 | 
| 
 | 
| 
 Definition at line 1207 of file nc.c. References NC_check_id(), NC_indef, NC_readonly, NC_sync(), NC::nciop, read_NC(), and ncio::sync. Referenced by main(), and ncsync(). 
 01208 {
01209         int status;
01210         NC *ncp;
01211 
01212         status = NC_check_id(ncid, &ncp); 
01213         if(status != NC_NOERR)
01214                 return status;
01215 
01216         if(NC_indef(ncp))
01217                 return NC_EINDEFINE;
01218 
01219         if(NC_readonly(ncp))
01220         {
01221                 return read_NC(ncp);
01222         }
01223         /* else, read/write */
01224 
01225         status = NC_sync(ncp);
01226         if(status != NC_NOERR)
01227                 return status;
01228 
01229         return ncp->nciop->sync(ncp->nciop);
01230 }
 | 
| 
 | 
| 
 Definition at line 265 of file v2i.c. References nc_abort(), and nc_advise(). 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 763 of file v2i.c. References name, nc_advise(), and nc_copy_att(). 
 00770 {
00771         const int status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
00772         if(status != NC_NOERR)
00773         {
00774                 nc_advise("ncattcopy", status, "%s", name);
00775                 return -1;
00776         }
00777         return 0;
00778 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 818 of file v2i.c. References name, nc_advise(), and nc_del_att(). 
 00823 {
00824          const int status = nc_del_att(ncid, varid, name);
00825         if(status != NC_NOERR)
00826         {
00827                 nc_advise("ncattdel", status, "ncid %d", ncid);
00828                 return -1;
00829         }
00830         return 1;
00831 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 745 of file v2i.c. References name, nc_advise(), and nc_get_att(). 
 00751 {
00752         const int status = nc_get_att(ncid, varid, name, value);
00753         if(status != NC_NOERR)
00754         {
00755                 nc_advise("ncattget", status, "ncid %d", ncid);
00756                 return -1;
00757         }
00758         return 1;
00759 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 720 of file v2i.c. References name, nc_advise(), and nc_inq_att(). 
 00727 {
00728         size_t ll;
00729         const int status = nc_inq_att(ncid, varid, name, datatype, &ll);
00730         if(status != NC_NOERR)
00731         {
00732                 nc_advise("ncattinq", status, "ncid %d", ncid);
00733                 return -1;
00734         }
00735         
00736         if(len != NULL)
00737                 *len = (int) ll;
00738 
00739         return 1;
00740 
00741 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 782 of file v2i.c. References name, nc_advise(), and nc_inq_attname(). 
 00788 {
00789         const int status = nc_inq_attname(ncid, varid, attnum, name);
00790         if(status != NC_NOERR)
00791         {
00792                 nc_advise("ncattname", status, "ncid %d", ncid);
00793                 return -1;
00794         }
00795         return attnum;
00796 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 700 of file v2i.c. References name, nc_advise(), and nc_put_att(). Referenced by main(). 
 00708 {
00709         const int status = nc_put_att(ncid, varid, name, datatype, len, value);
00710         if(status != NC_NOERR)
00711         {
00712                 nc_advise("ncattput", status, "ncid %d", ncid);
00713                 return -1;
00714         }
00715         return 0;
00716 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 800 of file v2i.c. References name, nc_advise(), and nc_rename_att(). 
 00806 {
00807         const int status = nc_rename_att(ncid, varid, name, newname);
00808         if(status != NC_NOERR)
00809         {
00810                 nc_advise("ncattrename", status, "ncid %d", ncid);
00811                 return -1;
00812         }
00813         return 1;
00814 }
 | 
| 
 | 
| 
 Definition at line 205 of file v2i.c. References nc_advise(), and nc_close(). Referenced by main(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 151 of file v2i.c. References nc_advise(), and nc_create(). Referenced by main(). 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 278 of file v2i.c. References name, nc_advise(), and nc_def_dim(). Referenced by main(). 
 00283 {
00284         int dimid;
00285         const int status =  nc_def_dim(ncid, name, (size_t)length, &dimid);
00286         if(status != NC_NOERR)
00287         {
00288                 nc_advise("ncdimdef", status, "ncid %d", ncid);
00289                 return -1;
00290         }
00291         return dimid;
00292 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 296 of file v2i.c. References name, nc_advise(), and nc_inq_dimid(). 
 00297 {
00298         int dimid;
00299         const int status =  nc_inq_dimid(ncid, name, &dimid);
00300         if(status != NC_NOERR)
00301         {
00302                 nc_advise("ncdimid", status, "ncid %d", ncid);
00303                 return -1;
00304         }
00305         return dimid;
00306 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 310 of file v2i.c. References name, nc_advise(), and nc_inq_dim(). 
 00316 {
00317         size_t ll;
00318         const int status = nc_inq_dim(ncid, dimid, name, &ll);
00319 
00320         if(status != NC_NOERR)
00321         {
00322                 nc_advise("ncdiminq", status, "ncid %d", ncid);
00323                 return -1;
00324         }
00325         /* else */
00326         
00327         if(length != NULL)
00328                 *length = (int) ll;
00329 
00330         return dimid;
00331 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 335 of file v2i.c. References name, nc_advise(), and nc_rename_dim(). 
 00340 {
00341         const int status = nc_rename_dim(ncid, dimid, name);
00342         if(status != NC_NOERR)
00343         {
00344                 nc_advise("ncdimrename", status, "ncid %d", ncid);
00345                 return -1;
00346         }
00347         return dimid;
00348 }
 | 
| 
 | 
| 
 Definition at line 192 of file v2i.c. References nc_advise(), and nc_enddef(). Referenced by main(). 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 219 of file v2i.c. References nc_advise(), nc_inq(), and ndims. 
 00226 {
00227         int nd, nv, na;
00228         const int status = nc_inq(ncid, &nd, &nv, &na, recdim);
00229 
00230         if(status != NC_NOERR)
00231         {
00232                 nc_advise("ncinquire", status, "ncid %d", ncid);
00233                 return -1;
00234         }
00235         /* else */
00236 
00237         if(ndims != NULL)
00238                 *ndims = (int) nd;
00239 
00240         if(nvars != NULL)
00241                 *nvars = (int) nv;
00242 
00243         if(natts != NULL)
00244                 *natts = (int) na;
00245 
00246         return ncid;
00247 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 165 of file v2i.c. References nc_advise(), and nc_open(). 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 919 of file v2i.c. References nc_advise(), and nc_get_rec(). 
 00924 {
00925         const int status = nc_get_rec(ncid, (size_t)recnum, datap);
00926         if(status != NC_NOERR)
00927         {
00928                 nc_advise("ncrecget", status, "ncid %d", ncid);
00929                 return -1;
00930         }
00931         return 0;
00932 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 886 of file v2i.c. References nc_advise(), and nc_inq_rec(). 
 00892 {
00893         size_t nrv = 0;
00894         size_t rs[NC_MAX_VARS]; /* TODO */
00895         const int status = nc_inq_rec(ncid, &nrv, recvarids, rs);
00896         if(status != NC_NOERR)
00897         {
00898                 nc_advise("ncrecinq", status, "ncid %d", ncid);
00899                 return -1;
00900         }
00901 
00902         if(nrecvars != NULL)
00903                 *nrecvars = (int) nrv;
00904 
00905         if(recsizes != NULL)
00906         {
00907                 size_t ii;
00908                 for(ii = 0; ii < nrv; ii++)
00909                 {
00910                         recsizes[ii] = (long) rs[ii];
00911                 }
00912         }
00913 
00914         return (int) nrv;
00915 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 936 of file v2i.c. References nc_advise(), and nc_put_rec(). 
 00941 {
00942         const int status = nc_put_rec(ncid, (size_t)recnum, datap);
00943         if(status != NC_NOERR)
00944         {
00945                 nc_advise("ncrecput", status, "ncid %d", ncid);
00946                 return -1;
00947         }
00948         return 0;
00949 }
 | 
| 
 | 
| 
 Definition at line 179 of file v2i.c. References nc_advise(), and nc_redef(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 869 of file v2i.c. References nc_advise(), and nc_set_fill(). 
 00873 {
00874         int oldmode = -1;
00875         const int status = nc_set_fill(ncid, fillmode, &oldmode);
00876         if(status != NC_NOERR)
00877         {
00878                 nc_advise("ncsetfill", status, "ncid %d", ncid);
00879                 return -1;
00880         }
00881         return oldmode;
00882 }
 | 
| 
 | 
| 
 Definition at line 251 of file v2i.c. References nc_advise(), and nc_sync(). 
 | 
| 
 | 
| 
 Definition at line 842 of file v2i.c. References nc_advise(). Referenced by nc_get_varm(), nc_inq_rec(), and nc_put_varm(). 
 00843 {
00844         switch(type){
00845         case NC_BYTE :
00846         case NC_CHAR :
00847                 return((int)sizeof(char));
00848         case NC_SHORT :
00849                 return(int)(sizeof(short));
00850         case NC_INT :
00851                 return((int)sizeof(int));
00852         case NC_FLOAT :
00853                 return((int)sizeof(float));
00854         case NC_DOUBLE : 
00855                 return((int)sizeof(double));
00856         }
00857 
00858 #ifndef NO_NETCDF_2
00859         /* else */
00860         nc_advise("nctypelen", NC_EBADTYPE, "Unknown type %d",
00861                 (int)type);
00862 #endif /* NO_NETCDF_2 */
00863         return -1;
00864 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 352 of file v2i.c. References name, nc_advise(), nc_def_var(), and ndims. Referenced by main(). 
 00359 {
00360         int varid = -1;
00361         const int status = nc_def_var(ncid, name, datatype, ndims, dim, &varid);
00362         if(status != NC_NOERR)
00363         {
00364                 nc_advise("ncvardef", status, "ncid %d", ncid);
00365                 return -1;
00366         }
00367         return varid;
00368 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 497 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_get_vara(), ndims, and NDIMS_DECL. Referenced by ncvargets(). 
 00504 {
00505         NDIMS_DECL
00506         A_DECL(stp, size_t, ndims, start);
00507         A_DECL(cntp, size_t, ndims, count);
00508         A_INIT(stp, size_t, ndims, start);
00509         A_INIT(cntp, size_t, ndims, count);
00510         {
00511         const int status = nc_get_vara(ncid, varid, stp, cntp, value);
00512         A_FREE(cntp);
00513         A_FREE(stp);
00514         if(status != NC_NOERR)
00515         {
00516                 nc_advise("ncvarget", status, "ncid %d", ncid);
00517                 return -1;
00518         }
00519         }
00520         return 0;
00521 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 445 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_get_var1(), ndims, and NDIMS_DECL. 
 00451 {
00452         NDIMS_DECL
00453         A_DECL(coordp, size_t, ndims, index);
00454         A_INIT(coordp, size_t, ndims, index);
00455         {
00456         const int status = nc_get_var1(ncid, varid, coordp, value);
00457         A_FREE(coordp);
00458         if(status != NC_NOERR)
00459         {
00460                 nc_advise("ncdimid", status, "ncid %d", ncid);
00461                 return -1;
00462         }
00463         }
00464         return 0;
00465 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 641 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_get_varm(), ncvargets(), ndims, NDIMS_DECL, and stride. 
 00650 {
00651         if(map == NULL)
00652                 return ncvargets(ncid, varid, start, count, stride, value);
00653         /* else */
00654         {
00655         NDIMS_DECL
00656         A_DECL(stp, size_t, ndims, start);
00657         A_DECL(cntp, size_t, ndims, count);
00658         A_DECL(strdp, ptrdiff_t, ndims, stride);
00659         A_DECL(imp, ptrdiff_t, ndims, map);
00660         A_INIT(stp, size_t, ndims, start);
00661         A_INIT(cntp, size_t, ndims, count);
00662         A_INIT(strdp, ptrdiff_t, ndims, stride);
00663         A_INIT(imp, ptrdiff_t, ndims, map);
00664         {
00665         const int status = nc_get_varm(ncid, varid,
00666                         stp, cntp, strdp, imp, value);
00667         A_FREE(imp);
00668         A_FREE(strdp);
00669         A_FREE(cntp);
00670         A_FREE(stp);
00671         if(status != NC_NOERR)
00672         {
00673                 nc_advise("ncvargetg", status, "ncid %d", ncid);
00674                 return -1;
00675         }
00676         }
00677         return 0;
00678         }
00679 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 562 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_get_vars(), ncvarget(), ndims, NDIMS_DECL, and stride. Referenced by ncvargetg(). 
 00570 {
00571         if(stride == NULL)
00572                 return ncvarget(ncid, varid, start, count, value);
00573         /* else */
00574         {
00575         NDIMS_DECL
00576         A_DECL(stp, size_t, ndims, start);
00577         A_DECL(cntp, size_t, ndims, count);
00578         A_DECL(strdp, ptrdiff_t, ndims, stride);
00579         A_INIT(stp, size_t, ndims, start);
00580         A_INIT(cntp, size_t, ndims, count);
00581         A_INIT(strdp, ptrdiff_t, ndims, stride);
00582         {
00583         const int status = nc_get_vars(ncid, varid, stp, cntp, strdp, value);
00584         A_FREE(strdp);
00585         A_FREE(cntp);
00586         A_FREE(stp);
00587         if(status != NC_NOERR)
00588         {
00589                 nc_advise("ncvargets", status, "ncid %d", ncid);
00590                 return -1;
00591         }
00592         }
00593         return 0;
00594         }
00595 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 372 of file v2i.c. References name, nc_advise(), and nc_inq_varid(). 
 00376 {
00377         int varid = -1;
00378         const int status = nc_inq_varid(ncid, name, &varid);
00379         if(status != NC_NOERR)
00380         {
00381                 nc_advise("ncvarid", status, "ncid %d", ncid);
00382                 return -1;
00383         }
00384         return varid;
00385 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 389 of file v2i.c. References name, nc_advise(), nc_inq_var(), and ndims. 
 00398 {
00399         int nd, na;
00400         const int status = nc_inq_var(ncid, varid, name, datatype,
00401                  &nd, dim, &na);
00402 
00403         if(status != NC_NOERR)
00404         {
00405                 nc_advise("ncvarinq", status, "ncid %d", ncid);
00406                 return -1;
00407         }
00408         /* else */
00409         
00410         if(ndims != NULL)
00411                 *ndims = (int) nd;
00412 
00413         if(natts != NULL)
00414                 *natts = (int) na;
00415 
00416         return varid;
00417 }
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 469 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_put_vara(), ndims, and NDIMS_DECL. Referenced by main(), and ncvarputs(). 
 00476 {
00477         NDIMS_DECL
00478         A_DECL(stp, size_t, ndims, start);
00479         A_DECL(cntp, size_t, ndims, count);
00480         A_INIT(stp, size_t, ndims, start);
00481         A_INIT(cntp, size_t, ndims, count);
00482         {
00483         const int status = nc_put_vara(ncid, varid, stp, cntp, value);
00484         A_FREE(cntp);
00485         A_FREE(stp);
00486         if(status != NC_NOERR)
00487         {
00488                 nc_advise("ncvarput", status, "ncid %d", ncid);
00489                 return -1;
00490         }
00491         }
00492         return 0;
00493 }
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 421 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_put_var1(), ndims, and NDIMS_DECL. Referenced by main(). 
 00427 {
00428         NDIMS_DECL
00429         A_DECL(coordp, size_t, ndims, index);
00430         A_INIT(coordp, size_t, ndims, index);
00431         {
00432         const int status = nc_put_var1(ncid, varid, coordp, value);
00433         A_FREE(coordp);
00434         if(status != NC_NOERR)
00435         {
00436                 nc_advise("ncvarput1", status, "ncid %d", ncid);
00437                 return -1;
00438         }
00439         }
00440         return 0;
00441 }
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 599 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_put_varm(), ncvarputs(), ndims, NDIMS_DECL, and stride. 
 00608 {
00609         if(map == NULL)
00610                 return ncvarputs(ncid, varid, start, count, stride, value);
00611         /* else */
00612         {
00613         NDIMS_DECL
00614         A_DECL(stp, size_t, ndims, start);
00615         A_DECL(cntp, size_t, ndims, count);
00616         A_DECL(strdp, ptrdiff_t, ndims, stride);
00617         A_DECL(imp, ptrdiff_t, ndims, map);
00618         A_INIT(stp, size_t, ndims, start);
00619         A_INIT(cntp, size_t, ndims, count);
00620         A_INIT(strdp, ptrdiff_t, ndims, stride);
00621         A_INIT(imp, ptrdiff_t, ndims, map);
00622         {
00623         const int status = nc_put_varm(ncid, varid,
00624                          stp, cntp, strdp, imp, value);
00625         A_FREE(imp);
00626         A_FREE(strdp);
00627         A_FREE(cntp);
00628         A_FREE(stp);
00629         if(status != NC_NOERR)
00630         {
00631                 nc_advise("ncvarputg", status, "ncid %d", ncid);
00632                 return -1;
00633         }
00634         }
00635         return 0;
00636         }
00637 }
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 525 of file v2i.c. References A_DECL, A_FREE, A_INIT, nc_advise(), nc_put_vars(), ncvarput(), ndims, NDIMS_DECL, and stride. Referenced by ncvarputg(). 
 00533 {
00534         if(stride == NULL)
00535                 return ncvarput(ncid, varid, start, count, value);
00536         /* else */
00537         {
00538         NDIMS_DECL
00539         A_DECL(stp, size_t, ndims, start);
00540         A_DECL(cntp, size_t, ndims, count);
00541         A_DECL(strdp, ptrdiff_t, ndims, stride);
00542         A_INIT(stp, size_t, ndims, start);
00543         A_INIT(cntp, size_t, ndims, count);
00544         A_INIT(strdp, ptrdiff_t, ndims, stride);
00545         {
00546         const int status = nc_put_vars(ncid, varid, stp, cntp, strdp, value);
00547         A_FREE(strdp);
00548         A_FREE(cntp);
00549         A_FREE(stp);
00550         if(status != NC_NOERR)
00551         {
00552                 nc_advise("ncvarputs", status, "ncid %d", ncid);
00553                 return -1;
00554         }
00555         }
00556         return 0;
00557         }
00558 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 683 of file v2i.c. References name, nc_advise(), and nc_rename_var(). 
 00688 {
00689         const int status = nc_rename_var(ncid, varid, name);
00690         if(status != NC_NOERR)
00691         {
00692                 nc_advise("ncvarrename", status, "ncid %d", ncid);
00693                 return -1;
00694         }
00695         return varid;
00696 }
 | 
Variable Documentation
| 
 | 
| 
 | 
| 
 | 
| 
 | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  