20#include "nc4internal.h"
21#include "nc4dispatch.h"
22#include "ncdispatch.h"
47nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var,
49 size_t *lenp,
int *attnum,
void *data)
51 NC_ATT_INFO_T *att = NULL;
53 int need_to_convert = 0;
60 LOG((3,
"%s: mem_type %d", __func__, mem_type));
72 if ((retval = nc4_find_grp_att(grp, varid, name, my_attnum, &att)))
78 mem_type = att->nc_typeid;
93 *xtype = att->nc_typeid;
95 *attnum = att->hdr.id;
103 if ((retval = nc4_get_typelen_mem(h5, mem_type, &type_size)))
109 if (data && att->len && mem_type != att->nc_typeid &&
114 if (!(bufr = malloc((
size_t)(att->len) * type_size)))
117 if ((retval = nc4_convert_type(att->data, bufr, att->nc_typeid,
118 mem_type, (
size_t)att->len, &range_error,
143 if((retval = NC_copy_data(h5->controller,mem_type,bufr,att->len,data)))
178nc4_get_att(
int ncid,
int varid,
const char *name,
nc_type *xtype,
179 nc_type mem_type,
size_t *lenp,
int *attnum,
void *data)
183 NC_VAR_INFO_T *var = NULL;
187 LOG((3,
"%s: ncid 0x%x varid %d mem_type %d", __func__, ncid,
191 if ((retval = nc4_find_grp_h5(ncid, &grp, &h5)))
198 if (!(var = (NC_VAR_INFO_T*)ncindexith(grp->vars,(
size_t)varid)))
200 assert(var->hdr.id == varid);
208 if ((retval = nc4_normalize_name(name, norm_name)))
211 return nc4_get_att_ptrs(h5, grp, var, norm_name, xtype, mem_type, lenp,
230NC4_inq_att(
int ncid,
int varid,
const char *name,
nc_type *xtypep,
233 LOG((2,
"%s: ncid 0x%x varid %d name %s", __func__, ncid, varid, name));
234 return nc4_get_att(ncid, varid, name, xtypep,
NC_NAT, lenp, NULL, NULL);
249NC4_inq_attid(
int ncid,
int varid,
const char *name,
int *attnump)
251 LOG((2,
"%s: ncid 0x%x varid %d name %s", __func__, ncid, varid, name));
252 return nc4_get_att(ncid, varid, name, NULL,
NC_NAT, NULL, attnump, NULL);
268NC4_inq_attname(
int ncid,
int varid,
int attnum,
char *name)
273 LOG((2,
"nc_inq_attname: ncid 0x%x varid %d attnum %d", ncid, varid,
277 if ((retval = nc4_find_nc_att(ncid, varid, NULL, attnum, &att)))
282 strcpy(name, att->hdr.name);
301NC4_get_att(
int ncid,
int varid,
const char *name,
void *value,
nc_type memtype)
303 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.
#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.