Next: , Previous: nc_def_vlen, Up: User Defined Data Types


5.23 Learning about a Variable Length Array (VLEN) Type: nc_inq_vlen

Use this type to learn about a vlen.

Usage

     nc_inq_vlen(int ncid, nc_type xtype, char *name, size_t *datum_sizep,
                 nc_type *base_nc_typep);
ncid
The ncid of the file that contains the VLEN type.
xtype
The type of the VLEN to inquire about.
name
A pointer for storage for the types name. The name will be NC_MAX_NAME characters or less.
datum_sizep
A pointer to a size_t, this will get the size of one element of this vlen.
base_nc_typep
A pointer to an nc_type, this will get the type of the VLEN base type. (In other words, what type is this a VLEN of?)

Errors

NC_NOERR
No error.
NC_EBADTYPE
Can't find the typeid.
NC_EBADID
ncid invalid.
NC_EBADGRPID
Group ID part of ncid was invalid.

Example

           if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
           if (nc_def_vlen(ncid, "name1", NC_INT, &typeid)) ERR;
           if (nc_inq_vlen(ncid, typeid, name_in, &size_in, &base_nc_type_in)) ERR;
           if (base_nc_type_in != NC_INT || (size_in != sizeof(int) || strcmp(name_in, VLEN_NAME))) ERR;
           if (nc_inq_user_type(ncid, typeid, name_in, &size_in, &base_nc_type_in, NULL, &class_in)) ERR;
           if (base_nc_type_in != NC_INT || (size_in != sizeof(int) || strcmp(name_in, VLEN_NAME))) ERR;
           if (nc_inq_compound(ncid, typeid, name_in, &size_in, NULL) != NC_EBADTYPE) ERR;
           if (nc_put_att(ncid, NC_GLOBAL, ATT_NAME, typeid, DIM_LEN, data)) ERR;
           if (nc_close(ncid)) ERR;