Main Content

netcdf.inqUserType

Return information about user-defined type

Description

example

[typeName,byteSize,baseTypeID,numFields,classID] = netcdf.inqUserType(ncid,typeID) returns information about the user-defined type specified by the numeric type identifier in the file identified by ncid. The output arguments include the name of the user-defined type, the size in bytes of the type, the numeric identifier of the base type, the number of fields, and the class identifier of the user-defined type. Not all returned information is applicable for all user-defined types. The netcdf.inqUserType function corresponds to the nc_inq_user_type function in the NetCDF library C API.

Examples

collapse all

Define an NC_VLEN type in a new NetCDF4 file and return information about it. An NC_VLEN type is a variable length array.

Create a new NetCDF4 file named myfile.nc.

source = "myfile.nc";
cmode = "NETCDF4";
ncid = netcdf.create(source,cmode); 

Define a new NC_VLEN type with the MY_VLEN type name and NC_DOUBLE base type.

typeName = "MY_VLEN";
baseType = "NC_DOUBLE";
typeID = netcdf.defVlen(ncid,typeName,baseType); 

Return information about the NC_VLEN type using its numeric type identifier typeID.

[typeName,byteSize,baseTypeID,numFields, ...
    classID] = netcdf.inqUserType(ncid,typeID)
typeName = 
'MY_VLEN'
byteSize = 16
baseTypeID = 6
numFields = 0
classID = 13

The results include:

  • Name of the type

  • Size in bytes of the type

  • Numeric identifier of the base type

  • Number of fields (0 because it is not applicable for NC_VLEN types)

  • Identifier of the NC_VLEN class of user-defined types

Return the identifier of the NC_VLEN class. 13 is the identifier of the NC_VLEN class.

netcdf.getConstant("NC_VLEN")
ans = 13

Close the NetCDF file.

netcdf.close(ncid)

Input Arguments

collapse all

File identifier of an open NetCDF file or OPeNDAP NetCDF data source, specified as an integer. You can retrieve this identifier by using the netcdf.open function.

Data Types: double

Data type identifier, specified as an integer. You can retrieve this identifier by using the netcdf.inqAtt or netcdf.inqVar functions.

Data Types: double

Output Arguments

collapse all

Name of the user-defined type, returned as a character vector.

Size in bytes of the user-defined type, returned as a double.

Type identifier for the base type of the user-defined type, returned as a double. For user-defined NC_VLEN types, the baseTypeID represents the type of the elements inside the user-defined variable-length array.

This returned information is not applicable for all user-defined types. The netcdf.inqUserType function returns baseTypeID as 0 when it is not applicable for the class of the specified user-defined type.

Number of fields of the user-defined type, returned as a double. This returned information is not applicable for all user-defined types. The netcdf.inqUserType function returns numFields as 0 when it is not applicable for the class of the specified user-defined type.

Class identifier of the user-defined type, returned as a double. For NC_VLEN types, the class identifier is 13. You can use the netcdf.getConstant function to return this identifier.

Version History

Introduced in R2022a