14#include "nc4internal.h"
15#include "nc4dispatch.h"
40 LOG((2,
"nc_inq_typeids: ncid 0x%x", ncid));
49 for(
size_t i=0;i<ncindexsize(grp->type);i++)
51 if((type = (NC_TYPE_INFO_T*)ncindexith(grp->type,i)) == NULL)
continue;
53 typeids[num] = type->hdr.id;
87 LOG((2,
"nc_inq_type: ncid 0x%x typeid %d", ncid, typeid1));
90 if (typeid1 < NUM_ATOMIC_TYPES)
92 if((retval=NC4_inq_atomic_type(typeid1, name, size)))
return retval;
101 if (!(type = nclistget(grp->nc4_info->alltypes, (
size_t)typeid1)))
105 strcpy(name, type->hdr.name);
109 if (type->nc_type_class ==
NC_VLEN)
136 nc_type *base_nc_typep,
size_t *nfieldsp,
int *classp)
139 NC_TYPE_INFO_T *type;
142 LOG((2,
"nc_inq_user_type: ncid 0x%x typeid %d", ncid, typeid1));
149 if (!(type = nclistget(grp->nc4_info->alltypes, (
size_t)typeid1)))
156 *nfieldsp = nclistlength(type->u.c.field);
157 else if (type->nc_type_class ==
NC_ENUM)
158 *nfieldsp = nclistlength(type->u.e.enum_member);
166 if (type->nc_type_class ==
NC_VLEN)
168 else if (type->nc_type_class ==
NC_STRING) {
169 if((retval=
NC4_inq_type(ncid,typeid1,NULL,size)))
return retval;
174 strcpy(name, type->hdr.name);
180 if (type->nc_type_class ==
NC_ENUM)
181 *base_nc_typep = type->u.e.base_nc_typeid;
182 else if (type->nc_type_class ==
NC_VLEN)
183 *base_nc_typep = type->u.v.base_nc_typeid;
191 *classp = type->nc_type_class;
215 size_t *offsetp,
nc_type *field_typeidp,
int *ndimsp,
219 NC_TYPE_INFO_T *type;
220 NC_FIELD_INFO_T *field;
228 if (!(type = nclistget(grp->nc4_info->alltypes, (
size_t)typeid1)))
232 if (!(field = nclistget(type->u.c.field, (
size_t)fieldid)))
236 strcpy(name, field->hdr.name);
238 *offsetp = field->offset;
240 *field_typeidp = field->nc_typeid;
242 *ndimsp = field->ndims;
244 for (d = 0; d < field->ndims; d++)
245 dim_sizesp[d] = field->dim_size[d];
268 NC_TYPE_INFO_T *type;
269 NC_FIELD_INFO_T *field;
274 LOG((2,
"nc_inq_compound_fieldindex: ncid 0x%x typeid %d name %s",
275 ncid, typeid1, name));
294 for (i = 0; i < nclistlength(type->u.c.field); i++)
296 field = nclistget(type->u.c.field, i);
298 if (!strcmp(field->hdr.name, norm_name))
307 *fieldidp = field->hdr.id;
331 NC_TYPE_INFO_T *type;
332 NC_ENUM_MEMBER_INFO_T *enum_member;
338 LOG((3,
"nc_inq_enum_ident: xtype %d value %d\n", xtype, value));
345 if (!(type = nclistget(grp->nc4_info->alltypes, (
size_t)xtype)))
349 if (type->nc_type_class !=
NC_ENUM)
353 for (found = 0, i = 0; i < nclistlength(type->u.e.enum_member); i++)
355 enum_member = nclistget(type->u.e.enum_member, i);
357 switch (type->u.e.base_nc_typeid)
360 ll_val = *(
char *)enum_member->value;
363 ll_val = *(
unsigned char *)enum_member->value;
366 ll_val = *(
short *)enum_member->value;
369 ll_val = *(
unsigned short *)enum_member->value;
372 ll_val = *(
int *)enum_member->value;
375 ll_val = *(
unsigned int *)enum_member->value;
379 ll_val = *(
long long *)enum_member->value;
384 LOG((4,
"ll_val=%d", ll_val));
388 strcpy(identifier, enum_member->name);
397 strcpy(identifier, NC_UNDEFINED_ENUM_IDENT);
426 NC_TYPE_INFO_T *type;
427 NC_ENUM_MEMBER_INFO_T *enum_member;
430 LOG((2,
"nc_inq_enum_member: ncid 0x%x typeid %d", ncid, typeid1));
437 if (!(type = nclistget(grp->nc4_info->alltypes, (
size_t)typeid1)))
441 if (type->nc_type_class !=
NC_ENUM)
445 if (!(enum_member = nclistget(type->u.e.enum_member, (
size_t)idx)))
450 strcpy(identifier, enum_member->name);
452 memcpy(value, enum_member->value, type->size);
475 NC_GRP_INFO_T *grptwo;
477 NC_TYPE_INFO_T *type = NULL;
478 char *norm_name = NULL;
482 for (i = 0; i < NUM_ATOMIC_TYPES; i++)
483 if (!strcmp(name, nc4_atomic_name[i]))
498 if (name[0] !=
'/' && strstr(name,
"/"))
502 if (!(norm_name = (
char*)malloc(strlen(name) + 1)))
510 int rootncid = (grp->nc4_info->root_grp->hdr.id | grp->nc4_info->controller->ext_ncid);
512 char* lastname = strrchr(norm_name,
'/');
513 if(lastname == norm_name)
522 type = (NC_TYPE_INFO_T*)ncindexlookup(grp->type,lastname);
529 for (grptwo = grp; grptwo; grptwo = grptwo->parent) {
530 type = (NC_TYPE_INFO_T*)ncindexlookup(grptwo->type,norm_name);
534 *typeidp = type->hdr.id;
544 *typeidp = type->hdr.id;
572 LOG((4,
"%s xtype: %d", __func__, xtype));
612 NC_TYPE_INFO_T *type;
620 *type_class = type->nc_type_class;
643 NC_FILE_INFO_T* h5 = NULL;
644 NC_TYPE_INFO_T* typ = NULL;
646 if(xtype <
NC_STRING) {f = 1;
goto done;}
647 if(xtype ==
NC_STRING) {f = 0;
goto done;}
657 if(fixedsizep) *fixedsizep = f;
675 NC_FILE_INFO_T* file = NULL;
676 NC_TYPE_INFO_T* utype = NULL;
678 if(subtype ==
NC_STRING) {parenttype->varsized = 1;
goto done;}
680 file = parenttype->container->nc4_info;
682 switch (utype->nc_type_class) {
684 case NC_VLEN: parenttype->varsized = 1;
break;
685 case NC_COMPOUND:
if(utype->varsized) parenttype->varsized = 1;
break;
702 if(typ->hdr.id ==
NC_STRING) {typ->varsized = 1;
goto done;}
703 switch (typ->nc_type_class) {
705 case NC_VLEN: typ->varsized = 1;
break;
720 NC_TYPE_INFO_T* vtype = NULL;
723 vtype = var->type_info;
726 return vtype->varsized;
int NC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
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_var_varsized(NC_VAR_INFO_T *var)
Test if a variable's type is fixed sized or not.
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_recheck_varsize(NC_TYPE_INFO_T *parenttype, nc_type subtype)
For types with one or more subtypes (e.g.
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)
int NC4_inq_type_fixed_size(int ncid, nc_type xtype, int *fixedsizep)
int NC4_set_varsize(NC_TYPE_INFO_T *typ)
When creating a type, mark it as variable-sized if known for sure.
#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_OPAQUE
opaque types
#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.