20 #include "nc4internal.h"
21 #include "nc4dispatch.h"
22 #include "ncdispatch.h"
46 nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var,
48 size_t *lenp,
int *attnum,
void *data)
50 NC_ATT_INFO_T *att = NULL;
52 int need_to_convert = 0;
59 LOG((3,
"%s: mem_type %d", __func__, mem_type));
71 if ((retval = nc4_find_grp_att(grp, varid, name, my_attnum, &att)))
77 mem_type = att->nc_typeid;
92 *xtype = att->nc_typeid;
94 *attnum = att->hdr.id;
102 if ((retval = nc4_get_typelen_mem(h5, mem_type, &type_size)))
108 if (data && att->len && mem_type != att->nc_typeid &&
113 if (!(bufr = malloc((
size_t)(att->len * type_size))))
116 if ((retval = nc4_convert_type(att->data, bufr, att->nc_typeid,
117 mem_type, (
size_t)att->len, &range_error,
145 nc_hvl_t *vldest = data;
146 NC_TYPE_INFO_T *type;
150 if ((retval = nc4_find_type(h5, att->nc_typeid, &type)))
154 if ((retval = nc4_get_typelen_mem(h5, type->u.v.base_nc_typeid, &base_typelen)))
157 for (i = 0; i < att->len; i++)
159 vldest[i].len = att->vldata[i].len;
160 if (!(vldest[i].p = malloc(vldest[i].len * base_typelen)))
162 memcpy(vldest[i].p, att->vldata[i].p, vldest[i].len * base_typelen);
165 else if (att->stdata)
168 for (i = 0; i < att->len; i++)
173 if (!(((
char **)data)[i] = strdup(att->stdata[i])))
177 ((
char **)data)[i] = att->stdata[i];
182 memcpy(data, bufr, (
size_t)(att->len * type_size));
186 if((retval =
nc_copy_data(h5->controller->ext_ncid,mem_type,bufr,att->len,data)))
222 nc4_get_att(
int ncid,
int varid,
const char *name,
nc_type *xtype,
223 nc_type mem_type,
size_t *lenp,
int *attnum,
void *data)
227 NC_VAR_INFO_T *var = NULL;
231 LOG((3,
"%s: ncid 0x%x varid %d mem_type %d", __func__, ncid,
235 if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
242 if (!(var = (NC_VAR_INFO_T*)ncindexith(grp->vars,varid)))
244 assert(var->hdr.id == varid);
252 if ((retval = nc4_normalize_name(name, norm_name)))
255 return nc4_get_att_ptrs(h5, grp, var, norm_name, xtype, mem_type, lenp,
274 NC4_inq_att(
int ncid,
int varid,
const char *name,
nc_type *xtypep,
277 LOG((2,
"%s: ncid 0x%x varid %d name %s", __func__, ncid, varid, name));
278 return nc4_get_att(ncid, varid, name, xtypep,
NC_NAT, lenp, NULL, NULL);
293 NC4_inq_attid(
int ncid,
int varid,
const char *name,
int *attnump)
295 LOG((2,
"%s: ncid 0x%x varid %d name %s", __func__, ncid, varid, name));
296 return nc4_get_att(ncid, varid, name, NULL,
NC_NAT, NULL, attnump, NULL);
312 NC4_inq_attname(
int ncid,
int varid,
int attnum,
char *name)
317 LOG((2,
"nc_inq_attname: ncid 0x%x varid %d attnum %d", ncid, varid,
321 if ((retval = nc4_find_nc_att(ncid, varid, NULL, attnum, &att)))
326 strcpy(name, att->hdr.name);
345 NC4_get_att(
int ncid,
int varid,
const char *name,
void *value,
nc_type memtype)
347 return nc4_get_att(ncid, varid, name, NULL, memtype, NULL, NULL, value);
#define NC_ECHAR
Attempt to convert between text & numbers.
#define NC_BYTE
signed 1 byte integer
#define NC_NAT
Not A Type.
#define NC_UBYTE
unsigned 1 byte int
#define NC_ENOMEM
Memory allocation (malloc) failure.
EXTERNL int nc_copy_data(int ncid, nc_type xtypeid, const void *memory, size_t count, void *copy)
Copy vector of arbitrary type instances.
#define NC_GLOBAL
Attribute id to put/get a global attribute.
#define NC_ENOTVAR
Variable not found.
#define NC_CLASSIC_MODEL
Enforce classic model on netCDF-4.
#define NC_MAX_NAME
Maximum for classic library.
#define NC_NOERR
No Error.
#define NC_NOQUANTIZE
No quantization in use.
#define NC_EBADNAME
Attribute or variable name contains illegal characters.
#define NC_CHAR
ISO/ASCII character.
#define NC_ERANGE
Math result not representable.
int nc_type
The nc_type type is just an int.