Rate This Document
Findability
Accuracy
Completeness
Readability

Querying Variable Information

Function Syntax

  • Query variable information.

    nc_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp)

  • Query the number of dimensions for a variable.

    nc_inq_varndims(int ncid, int varid, int *ndimsp)

  • Query the dimension IDs for a variable.

    nc_inq_vardimid(int ncid, int varid, int *dimidsp)

  • Query a variable ID by name.

    nc_inq_varid(int ncid, const char *name, int *varidp)

Parameters

Parameter

Description

Value Range

Input/Output

ncid

File ID

Non-negative integer

Input

varid

Variable ID

Non-negative integer

Input

const *name

Variable name

Non-empty string of less than 256 bytes

Input

*name

Pointer to the variable name

Non-empty

Output

*xtypep

Pointer to the variable data type

Non-empty

Output

*ndimsp

Pointer to the number of variable dimensions

Non-empty

Output

*dimidsp

Pointer to the array of variable dimension IDs

Non-empty

Output

*nattsp

Pointer to the number of variable attributes

Non-empty

Output

*varidp

Pointer to the variable ID

Non-empty

Output

Return Value

  • Success: NC_NOERR
  • Failure: An error code is returned.

Error Code

Error Code

Description

NC_EBADID

Invalid ncid

NC_ENOTVAR

Invalid variable ID

Notes

*name, *xtypep, *ndimsp, *dimidsp, *nattsp, and *varidp can be null pointers only if no data needs to be obtained.