Query data
Querying data is useful in understanding the structure of the dataset, especially while reading the dataset from a file. From the
application's perspective, it provides a mechanism to map the dataset to appropriate data structures within the application. For example, the
ncmpi_inq_dimXX()
family of functions may be used to inquire about the dimensions of a given dataset, which can in turn be used to construct multi-dimensional arrays.
Following are a few types of functions for making
queries using the PnetCDF API.
Querying a variable
There are quite a few functions of the form ncmpi_inq_varXX()
for retrieving information about a PnetCDF variable. As examples:
int ncmpi_inq_varid(int ncid, const char *name, int *varid)
Returns a pointer varid to the variable ID corresponding to the variable name. One can use this ID while making other inquiries about the variable as shown below.
int ncmpi_inq_varname(int ncid, int varid, char *name)
Returns the variable name corresponding to the variable id varid.
int ncmpi_inq_vartype(int ncid, int varid, nc_type *type)
Returns the type of the variable represented by varid. For example, it would be one of NC_FLOAT
, NC_INT
and so on.
int ncmpi_inq_vardimid(int ncid, int varid, int dimids[])
Returns a vector of dimension IDs corresponding to varid.
Querying a dimension
int ncmpi_inq_dimid(int ncid, const char *dim_name, int *dimid)
Returns a pointer dimid for a given dimension name dim_name. One can use this ID for retrieving information about a particular dimension. For example, the next function accepts the dimid as an argument.
int ncmpi_inq_dimlen(int ncid, int dimid, MPI_Offset *length)
Returns the length of the dimension corresponding to the dimension id dimid.
Querying a file
int ncmpi_inq_put_size(int ncid, MPI_Offset *size)
int ncmpi_inq_get_size(int ncid, MPI_Offset *size)
Returns in "size" the amount of data that were written (ncmpi_inq_put_size()
) or read (ncmpi_inq_get_size()
)
to/from a netCDF file since creating or opening the file.
int ncmpi_inq_file_info(int ncid, MPI_Info *info)
Returns in info (an MPI_Info
object) the I/O hints used by the PnetCDF library for the file.