14#include "nc4internal.h"
15#include "nc4dispatch.h"
19#define NC_CHAR_LEN sizeof(char)
20#define NC_STRING_LEN sizeof(char *)
25#define NC_DOUBLE_LEN 8
30 "short",
"int",
"float",
33 "int64",
"uint64",
"string"};
61 LOG((2,
"nc_inq_typeids: ncid 0x%x", ncid));
71 for(i=0;i<ncindexsize(grp->type);i++)
73 if((type = (NC_TYPE_INFO_T*)ncindexith(grp->type,i)) == NULL)
continue;
75 typeids[num] = type->hdr.id;
103 LOG((2,
"nc_inq_atomic_type: typeid %d", typeid1));
105 if (typeid1 >= NUM_ATOMIC_TYPES)
110 *size = nc4_atomic_size[typeid1];
130 LOG((2,
"nc_lookup_atomic_type: name %s ", name));
132 if (name == NULL || strlen(name) == 0)
134 for(i=0;i<NUM_ATOMIC_TYPES;i++) {
137 if(sizep) *sizep = nc4_atomic_size[i];
162 NC_TYPE_INFO_T *type;
166 LOG((2,
"nc_inq_type: ncid 0x%x typeid %d", ncid, typeid1));
169 if (typeid1 < NUM_ATOMIC_TYPES)
174 *size = nc4_atomic_size[typeid1];
183 if (!(type = nclistget(grp->nc4_info->alltypes, typeid1)))
187 strcpy(name, type->hdr.name);
191 if (type->nc_type_class ==
NC_VLEN)
193 else if (type->nc_type_class ==
NC_STRING)
220 nc_type *base_nc_typep,
size_t *nfieldsp,
int *classp)
223 NC_TYPE_INFO_T *type;
226 LOG((2,
"nc_inq_user_type: ncid 0x%x typeid %d", ncid, typeid1));
233 if (!(type = nclistget(grp->nc4_info->alltypes, typeid1)))
240 *nfieldsp = nclistlength(type->u.c.field);
241 else if (type->nc_type_class ==
NC_ENUM)
242 *nfieldsp = nclistlength(type->u.e.enum_member);
250 if (type->nc_type_class ==
NC_VLEN)
252 else if (type->nc_type_class ==
NC_STRING)
258 strcpy(name, type->hdr.name);
264 if (type->nc_type_class ==
NC_ENUM)
265 *base_nc_typep = type->u.e.base_nc_typeid;
266 else if (type->nc_type_class ==
NC_VLEN)
267 *base_nc_typep = type->u.v.base_nc_typeid;
275 *classp = type->nc_type_class;
299 size_t *offsetp,
nc_type *field_typeidp,
int *ndimsp,
303 NC_TYPE_INFO_T *type;
304 NC_FIELD_INFO_T *field;
312 if (!(type = nclistget(grp->nc4_info->alltypes, typeid1)))
316 if (!(field = nclistget(type->u.c.field,fieldid)))
320 strcpy(name, field->hdr.name);
322 *offsetp = field->offset;
324 *field_typeidp = field->nc_typeid;
326 *ndimsp = field->ndims;
328 for (d = 0; d < field->ndims; d++)
329 dim_sizesp[d] = field->dim_size[d];
352 NC_TYPE_INFO_T *type;
353 NC_FIELD_INFO_T *field;
358 LOG((2,
"nc_inq_compound_fieldindex: ncid 0x%x typeid %d name %s",
359 ncid, typeid1, name));
378 for (i = 0; i < nclistlength(type->u.c.field); i++)
380 field = nclistget(type->u.c.field, i);
382 if (!strcmp(field->hdr.name, norm_name))
391 *fieldidp = field->hdr.id;
414 NC_TYPE_INFO_T *type;
415 NC_ENUM_MEMBER_INFO_T *enum_member;
421 LOG((3,
"nc_inq_enum_ident: xtype %d value %d\n", xtype, value));
428 if (!(type = nclistget(grp->nc4_info->alltypes, xtype)))
432 if (type->nc_type_class !=
NC_ENUM)
436 for (found = 0, i = 0; i < nclistlength(type->u.e.enum_member); i++)
438 enum_member = nclistget(type->u.e.enum_member, i);
440 switch (type->u.e.base_nc_typeid)
443 ll_val = *(
char *)enum_member->value;
446 ll_val = *(
unsigned char *)enum_member->value;
449 ll_val = *(
short *)enum_member->value;
452 ll_val = *(
unsigned short *)enum_member->value;
455 ll_val = *(
int *)enum_member->value;
458 ll_val = *(
unsigned int *)enum_member->value;
462 ll_val = *(
long long *)enum_member->value;
467 LOG((4,
"ll_val=%d", ll_val));
471 strcpy(identifier, enum_member->name);
505 NC_TYPE_INFO_T *type;
506 NC_ENUM_MEMBER_INFO_T *enum_member;
509 LOG((2,
"nc_inq_enum_member: ncid 0x%x typeid %d", ncid, typeid1));
516 if (!(type = nclistget(grp->nc4_info->alltypes, typeid1)))
520 if (type->nc_type_class !=
NC_ENUM)
524 if (!(enum_member = nclistget(type->u.e.enum_member, idx)))
529 strcpy(identifier, enum_member->name);
531 memcpy(value, enum_member->value, type->size);
554 NC_GRP_INFO_T *grptwo;
556 NC_TYPE_INFO_T *type = NULL;
561 for (i = 0; i < NUM_ATOMIC_TYPES; i++)
577 if (name[0] !=
'/' && strstr(name,
"/"))
581 if (!(norm_name = (
char*)malloc(strlen(name) + 1)))
588 for (grptwo = grp; grptwo; grptwo = grptwo->parent) {
589 type = (NC_TYPE_INFO_T*)ncindexlookup(grptwo->type,norm_name);
593 *typeidp = type->hdr.id;
603 *typeidp = type->hdr.id;
631 LOG((4,
"%s xtype: %d", __func__, xtype));
671 NC_TYPE_INFO_T *type;
679 *type_class = type->nc_type_class;
NC_TYPE_INFO_T * nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name)
int nc4_find_nc4_grp(int ncid, NC_GRP_INFO_T **grp)
int nc4_find_grp_h5(int ncid, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5)
int nc4_normalize_name(const char *name, char *norm_name)
int nc4_find_type(const NC_FILE_INFO_T *h5, nc_type typeid, NC_TYPE_INFO_T **type)
int NC4_inq_compound_fieldindex(int ncid, nc_type typeid1, const char *name, int *fieldidp)
int NC4_inq_user_type(int ncid, nc_type typeid1, char *name, size_t *size, nc_type *base_nc_typep, size_t *nfieldsp, int *classp)
int NC4_lookup_atomic_type(const char *name, nc_type *idp, size_t *sizep)
const char * nc4_atomic_name[NUM_ATOMIC_TYPES]
int NC4_inq_compound_field(int ncid, nc_type typeid1, int fieldid, char *name, size_t *offsetp, nc_type *field_typeidp, int *ndimsp, int *dim_sizesp)
int NC4_inq_atomic_type(nc_type typeid1, char *name, size_t *size)
EXTERNL int NC4_inq_typeid(int ncid, const char *name, nc_type *typeidp)
int NC4_inq_enum_member(int ncid, nc_type typeid1, int idx, char *identifier, void *value)
int NC4_inq_type(int ncid, nc_type typeid1, char *name, size_t *size)
int NC4_inq_typeids(int ncid, int *ntypes, int *typeids)
int NC4_inq_enum_ident(int ncid, nc_type xtype, long long value, char *identifier)
int nc4_get_typeclass(const NC_FILE_INFO_T *h5, nc_type xtype, int *type_class)
#define NC_EBADTYPE
Not a netcdf data type.
#define NC_EBADFIELD
Bad field ID.
#define NC_UINT
unsigned 4-byte int
#define NC_INT
signed 4 byte integer
#define NC_BYTE
signed 1 byte integer
#define NC_VLEN
vlen (variable-length) types
#define NC_NAT
Not A Type.
#define NC_DOUBLE
double precision floating point number
#define NC_UBYTE
unsigned 1 byte int
#define NC_FLOAT
single precision floating point number
#define NC_ENOMEM
Memory allocation (malloc) failure.
#define EXTERNL
Needed for DLL build.
#define NC_COMPOUND
compound types
#define NC_SHORT
signed 2 byte integer
#define NC_ENUM
enum types
#define NC_INT64
signed 8-byte int
#define NC_UINT64
unsigned 8-byte int
#define NC_EINVAL
Invalid Argument.
#define NC_MAX_NAME
Maximum for classic library.
#define NC_NOERR
No Error.
#define NC_USHORT
unsigned 2-byte int
#define NC_CHAR
ISO/ASCII character.
int nc_type
The nc_type type is just an int.
This is the type of arrays of vlens.