NetCDF
4.9.2
|
User defined types allow for more complex data structures. More...
Functions | |
int | nc_inq_type_equal (int ncid1, nc_type typeid1, int ncid2, nc_type typeid2, int *equal) |
Learn if two types are equal. More... | |
Learning about User-Defined Types | |
int | nc_inq_typeid (int ncid, const char *name, nc_type *typeidp) |
Find a type by name. More... | |
int | nc_inq_user_type (int ncid, nc_type xtype, char *name, size_t *size, nc_type *base_nc_typep, size_t *nfieldsp, int *classp) |
Learn about a user defined type. More... | |
Compound Types | |
int | nc_def_compound (int ncid, size_t size, const char *name, nc_type *typeidp) |
Create a compound type. More... | |
int | nc_insert_compound (int ncid, nc_type xtype, const char *name, size_t offset, nc_type field_typeid) |
Insert a named field into a compound type. More... | |
int | nc_insert_array_compound (int ncid, nc_type xtype, const char *name, size_t offset, nc_type field_typeid, int ndims, const int *dim_sizes) |
Insert a named array field into a compound type. More... | |
int | nc_inq_compound (int ncid, nc_type xtype, char *name, size_t *sizep, size_t *nfieldsp) |
Learn about a compound type. More... | |
int | nc_inq_compound_name (int ncid, nc_type xtype, char *name) |
Learn the name of a compound type. More... | |
int | nc_inq_compound_size (int ncid, nc_type xtype, size_t *sizep) |
Learn the size of a compound type. More... | |
int | nc_inq_compound_nfields (int ncid, nc_type xtype, size_t *nfieldsp) |
Learn the number of fields in a compound type. More... | |
int | nc_inq_compound_field (int ncid, nc_type xtype, int fieldid, char *name, size_t *offsetp, nc_type *field_typeidp, int *ndimsp, int *dim_sizesp) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fieldname (int ncid, nc_type xtype, int fieldid, char *name) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fieldoffset (int ncid, nc_type xtype, int fieldid, size_t *offsetp) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fieldtype (int ncid, nc_type xtype, int fieldid, nc_type *field_typeidp) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fieldndims (int ncid, nc_type xtype, int fieldid, int *ndimsp) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fielddim_sizes (int ncid, nc_type xtype, int fieldid, int *dim_sizesp) |
Get information about one of the fields of a compound type. More... | |
int | nc_inq_compound_fieldindex (int ncid, nc_type xtype, const char *name, int *fieldidp) |
Learn the Index of a Named Field in a Compound Type. More... | |
Enum Types | |
int | nc_def_enum (int ncid, nc_type base_typeid, const char *name, nc_type *typeidp) |
Create an enum type. More... | |
int | nc_insert_enum (int ncid, nc_type xtype, const char *name, const void *value) |
Insert a named member into a enum type. More... | |
int | nc_inq_enum (int ncid, nc_type xtype, char *name, nc_type *base_nc_typep, size_t *base_sizep, size_t *num_membersp) |
Learn about a user-define enumeration type. More... | |
int | nc_inq_enum_member (int ncid, nc_type xtype, int idx, char *name, void *value) |
Learn about a about a member of an enum type. More... | |
int | nc_inq_enum_ident (int ncid, nc_type xtype, long long value, char *identifier) |
Get the name which is associated with an enum member value. More... | |
Variable Length Array Types | |
int | nc_free_vlen (nc_vlen_t *vl) |
Free memory in a VLEN object. More... | |
int | nc_free_vlens (size_t len, nc_vlen_t vlens[]) |
Free an array of vlens given the number of elements and an array. More... | |
int | nc_def_vlen (int ncid, const char *name, nc_type base_typeid, nc_type *xtypep) |
Use this function to define a variable length array type. More... | |
int | nc_inq_vlen (int ncid, nc_type xtype, char *name, size_t *datum_sizep, nc_type *base_nc_typep) |
Learn about a VLEN type. More... | |
Opaque Types | |
int | nc_def_opaque (int ncid, size_t size, const char *name, nc_type *xtypep) |
Create an opaque type. More... | |
int | nc_inq_opaque (int ncid, nc_type xtype, char *name, size_t *sizep) |
Learn about an opaque type. More... | |
User defined types allow for more complex data structures.
NetCDF-4 has added support for four different user defined data types. User defined type may only be used in files created with the NC_NETCDF4 and without NC_CLASSIC_MODEL.
Users may construct user defined type with the various nc_def_* functions described in this section. They may learn about user defined types by using the nc_inq_ functions defined in this section.
Once types are constructed, define variables of the new type with nc_def_var (see nc_def_var). Write to them with nc_put_var1, nc_put_var, nc_put_vara, or nc_put_vars. Read data of user-defined type with nc_get_var1, nc_get_var, nc_get_vara, or nc_get_vars (see Variables).
Create attributes of the new type with nc_put_att (see nc_put_att_ type). Read attributes of the new type with nc_get_att (see Attributes).
int nc_def_compound | ( | int | ncid, |
size_t | size, | ||
const char * | name, | ||
nc_type * | typeidp | ||
) |
Create a compound type.
Provide an ncid, a name, and a total size (in bytes) of one element of the completed compound type.
After calling this function, fill out the type with repeated calls to nc_insert_compound(). Call nc_insert_compound() once for each field you wish to insert into the compound type.
ncid | NetCDF ID |
size | The size, in bytes, of the compound type. |
name | NetCDF Names of the created type. |
typeidp | The type ID of the new type is copied here. |
Definition at line 63 of file dcompound.c.
Create an enum type.
Provide an ncid, a name, and a base integer type.
After calling this function, fill out the type with repeated calls to nc_insert_enum(). Call nc_insert_enum() once for each value you wish to make part of the enumeration.
ncid | NetCDF ID |
base_typeid | The base integer type for this enum. Must be one of: NC_BYTE, NC_UBYTE, NC_SHORT, NC_USHORT, NC_INT, NC_UINT, NC_INT64, NC_UINT64. |
name | NetCDF Names of new type. |
typeidp | A pointer to an nc_type. The typeid of the new type will be placed there. |
int nc_def_opaque | ( | int | ncid, |
size_t | size, | ||
const char * | name, | ||
nc_type * | xtypep | ||
) |
Create an opaque type.
Provide a size and a name.
ncid | NetCDF ID |
size | The size of each opaque object in bytes. |
name | NetCDF Names of the new type. |
xtypep | Pointer where the new typeid for this type is returned. |
Use this function to define a variable length array type.
ncid | NetCDF ID |
name | NetCDF Names of new type. |
base_typeid | The typeid of the base type of the VLEN. For example, for a VLEN of shorts, the base type is NC_SHORT. This can be a user defined type. |
xtypep | A pointer to an nc_type variable. The typeid of the new VLEN type will be set here. |
int nc_free_vlen | ( | nc_vlen_t * | vl | ) |
Free memory in a VLEN object.
When you read VLEN type the library will actually allocate the storage space for the data. This storage space must be freed, so pass the pointer back to this function, when you're done with the data, and it will free the vlen memory.
The function nc_free_vlens() is more useful than this function, because it can free an array of VLEN objects.
WARNING: this code is incorrect because it will only work if the basetype of the vlen is
The reason is that to operate properly, it needs to recurse when the basetype is a complex object such as another vlen or compound.
This function is deprecated in favor of the function "nc_reclaim_data". See include/netcdf.h.
vl | pointer to the vlen object. |
int nc_free_vlens | ( | size_t | len, |
nc_vlen_t | vlens[] | ||
) |
Free an array of vlens given the number of elements and an array.
When you read VLEN type the library will actually allocate the storage space for the data. This storage space must be freed, so pass the pointer back to this function, when you're done with the data, and it will free the vlen memory.
WARNING: this code is incorrect because it will only work if the basetype of the vlen is
The reason is that to operate properly, it needs to recurse when the basetype is a complex object such as another vlen or compound.
This function is deprecated in favor of the function "nc_reclaim_data". See include/netcdf.h.
len | number of elements in the array. |
vlens | pointer to the vlen object. |
int nc_inq_compound | ( | int | ncid, |
nc_type | xtype, | ||
char * | name, | ||
size_t * | sizep, | ||
size_t * | nfieldsp | ||
) |
Learn about a compound type.
Get the number of fields, len, and name of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
name | Returned NetCDF Names of compound type. Ignored if NULL. |
sizep | Returned size of compound type in bytes. Ignored if NULL. |
nfieldsp | The number of fields in the compound type will be placed here. Ignored if NULL. |
Definition at line 175 of file dcompound.c.
int nc_inq_compound_field | ( | int | ncid, |
nc_type | xtype, | ||
int | fieldid, | ||
char * | name, | ||
size_t * | offsetp, | ||
nc_type * | field_typeidp, | ||
int * | ndimsp, | ||
int * | dim_sizesp | ||
) |
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
name | Returned NetCDF Names of the field. Ignored if NULL. |
offsetp | A pointer which will get the offset of the field. Ignored if NULL. |
field_typeidp | A pointer which will get the typeid of the field. Ignored if NULL. |
ndimsp | A pointer which will get the number of dimensions of the field. Ignored if NULL. |
dim_sizesp | A pointer which will get the dimension sizes of the field. Ignored if NULL. |
Definition at line 287 of file dcompound.c.
int nc_inq_compound_fielddim_sizes | ( | int | ncid, |
nc_type | xtype, | ||
int | fieldid, | ||
int * | dim_sizesp | ||
) |
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
dim_sizesp | A pointer which will get the dimension sizes of the field. Ignored if NULL. |
Definition at line 443 of file dcompound.c.
int nc_inq_compound_fieldindex | ( | int | ncid, |
nc_type | xtype, | ||
const char * | name, | ||
int * | fieldidp | ||
) |
Learn the Index of a Named Field in a Compound Type.
Get the index of a field in a compound type from the name.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
name | NetCDF Names of the field. Ignored if NULL. |
fieldidp | A pointer which will get the index of the named field. Ignored if NULL. |
Definition at line 475 of file dcompound.c.
int nc_inq_compound_fieldname | ( | int | ncid, |
nc_type | xtype, | ||
int | fieldid, | ||
char * | name | ||
) |
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
name | Returned NetCDF Names of the field. Ignored if NULL. |
Definition at line 321 of file dcompound.c.
int nc_inq_compound_fieldndims | ( | int | ncid, |
nc_type | xtype, | ||
int | fieldid, | ||
int * | ndimsp | ||
) |
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
ndimsp | A pointer which will get the number of dimensions of the field. Ignored if NULL. |
Definition at line 413 of file dcompound.c.
int nc_inq_compound_fieldoffset | ( | int | ncid, |
nc_type | xtype, | ||
int | fieldid, | ||
size_t * | offsetp | ||
) |
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
offsetp | A pointer which will get the offset of the field. Ignored if NULL. |
Definition at line 353 of file dcompound.c.
Get information about one of the fields of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
fieldid | A zero-based index number specifying a field in the compound type. |
field_typeidp | A pointer which will get the typeid of the field. Ignored if NULL. |
Definition at line 383 of file dcompound.c.
int nc_inq_compound_name | ( | int | ncid, |
nc_type | xtype, | ||
char * | name | ||
) |
Learn the name of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
name | Returned NetCDF Names of compound type. Ignored if NULL. |
Definition at line 203 of file dcompound.c.
int nc_inq_compound_nfields | ( | int | ncid, |
nc_type | xtype, | ||
size_t * | nfieldsp | ||
) |
Learn the number of fields in a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
nfieldsp | The number of fields in the compound type will be placed here. Ignored if NULL. |
Definition at line 249 of file dcompound.c.
int nc_inq_compound_size | ( | int | ncid, |
nc_type | xtype, | ||
size_t * | sizep | ||
) |
Learn the size of a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
sizep | Returned size of compound type in bytes. Ignored if NULL. |
Definition at line 226 of file dcompound.c.
int nc_inq_enum | ( | int | ncid, |
nc_type | xtype, | ||
char * | name, | ||
nc_type * | base_nc_typep, | ||
size_t * | base_sizep, | ||
size_t * | num_membersp | ||
) |
Learn about a user-define enumeration type.
ncid | NetCDF ID |
xtype | Typeid to inquire about. |
name | NetCDF Names of type will be copied here. Ignored if NULL. |
base_nc_typep | Typeid if the base type of the enum.Ignored if NULL. |
base_sizep | Pointer that will get the size in bytes of the base type. Ignored if NULL. |
num_membersp | Pointer that will get the number of members defined for this enum type. Ignored if NULL. |
int nc_inq_enum_ident | ( | int | ncid, |
nc_type | xtype, | ||
long long | value, | ||
char * | identifier | ||
) |
Get the name which is associated with an enum member value.
ncid | |
xtype | Typeid of the enum type. |
value | Value of interest. |
identifier | The identifier (NetCDF Names) of this value will be copied here; ignored_if_null. |
int nc_inq_enum_member | ( | int | ncid, |
nc_type | xtype, | ||
int | idx, | ||
char * | name, | ||
void * | value | ||
) |
Learn about a about a member of an enum type.
ncid | NetCDF ID |
xtype | Typeid of the enum type. |
idx | Index to the member to inquire about. |
name | The identifier (NetCDF Names) of this member will be copied here. Ignored if NULL. |
value | The value of this member will be copied here. Ignored if NULL. |
int nc_inq_opaque | ( | int | ncid, |
nc_type | xtype, | ||
char * | name, | ||
size_t * | sizep | ||
) |
Learn about an opaque type.
ncid | NetCDF ID |
xtype | Typeid to inquire about. |
name | The NetCDF Names of this type will be copied here. Ignored if NULL. |
sizep | The size of the type will be copied here. Ignored if NULL. |
Learn if two types are equal.
ncid1 | NetCDF ID of first typeid. |
typeid1 | First typeid. |
ncid2 | NetCDF ID of second typeid. |
typeid2 | Second typeid. |
equal | Pointer to int. A non-zero value will be copied here if the two types are equal, a zero if they are not equal. |
int nc_inq_typeid | ( | int | ncid, |
const char * | name, | ||
nc_type * | typeidp | ||
) |
Find a type by name.
Given a group ID and a type name, find the ID of the type. If the type is not found in the group, then the parents are searched. If still not found, the entire file is searched.
ncid | NetCDF ID |
name | NetCDF Names of type to search for. |
typeidp | Typeid of named type will be copied here, if it is found. |
int nc_inq_user_type | ( | int | ncid, |
nc_type | xtype, | ||
char * | name, | ||
size_t * | size, | ||
nc_type * | base_nc_typep, | ||
size_t * | nfieldsp, | ||
int * | classp | ||
) |
Learn about a user defined type.
Given an ncid and a typeid, get the information about a user defined type. This function will work on any user defined type, whether compound, opaque, enumeration, or variable length array.
ncid | NetCDF ID |
xtype | The typeid |
name | The NetCDF Names will be copied here. Ignored if NULL. |
size | the (in-memory) size of the type in bytes will be copied here. VLEN type size is the size of nc_vlen_t. String size is returned as the size of a character pointer. The size may be used to malloc space for the data, no matter what the type. Ignored if NULL. |
base_nc_typep | The base type will be copied here for enum and VLEN types. Ignored if NULL. |
nfieldsp | The number of fields will be copied here for enum and compound types. Ignored if NULL. |
classp | Return the class of the user defined type, NC_VLEN, NC_OPAQUE, NC_ENUM, or NC_COMPOUND. Ignored if NULL. |
int nc_inq_vlen | ( | int | ncid, |
nc_type | xtype, | ||
char * | name, | ||
size_t * | datum_sizep, | ||
nc_type * | base_nc_typep | ||
) |
Learn about a VLEN type.
ncid | NetCDF ID |
xtype | The type of the VLEN to inquire about. |
name | NetCDF Names of the type. Ignored if NULL. |
datum_sizep | A pointer to a size_t, this will get the size of one element of this vlen. Ignored if NULL. |
base_nc_typep | Pointer to get the base type of the VLEN. Ignored if NULL. |
int nc_insert_array_compound | ( | int | ncid, |
nc_type | xtype, | ||
const char * | name, | ||
size_t | offset, | ||
nc_type | field_typeid, | ||
int | ndims, | ||
const int * | dim_sizes | ||
) |
Insert a named array field into a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
name | The NetCDF Names of the new field. |
offset | Offset in byte from the beginning of the compound type for this field. |
field_typeid | The type of the field to be inserted. |
ndims | Number of dimensions in array. |
dim_sizes | Array of dimension sizes. |
Definition at line 141 of file dcompound.c.
int nc_insert_compound | ( | int | ncid, |
nc_type | xtype, | ||
const char * | name, | ||
size_t | offset, | ||
nc_type | field_typeid | ||
) |
Insert a named field into a compound type.
ncid | NetCDF ID |
xtype | The typeid for this compound type, as returned by nc_def_compound(), or nc_inq_var(). |
name | The NetCDF Names of the new field. |
offset | Offset in byte from the beginning of the compound type for this field. |
field_typeid | The type of the field to be inserted. |
Definition at line 99 of file dcompound.c.
int nc_insert_enum | ( | int | ncid, |
nc_type | xtype, | ||
const char * | name, | ||
const void * | value | ||
) |
Insert a named member into a enum type.
ncid | NetCDF ID |
xtype | |
name | The identifier (NetCDF Names) of the new member. |
value | The value that is to be associated with this member. |