Go to the previous, next section.

Get Information About Record Variables

The function ncrecinq returns information about the record variables (variables that use the unlimited dimension) in a netCDF file. The information returned is the number of record variables, their variable IDs, and the size (in bytes) for a record's worth of data for each record variable.

The ncrecinq function is not strictly necessary, since the information it returns can be computed from information returned by ncinquire, ncdiminq, and ncvarinq functions or their FORTRAN counterparts. This function is provided in the C interface for convenience only, to assist in using the C functions ncrecput and ncrecget.

In case of an error, ncrecinq returns -1. Possible causes of errors include:

ncrecinq: C Interface

int ncrecinq(int ncid, int* nrvars, int rvarids[], long rsizes[]);

ncid
NetCDF ID, returned from a previous call to ncopen or nccreate.

nrvars
Number of record variables.

rvarids
Returned vector of nrvars variable IDs for the record variables in this netCDF file. The caller must allocate enough space for a vector of at least nrvars integers to be returned. The maximum possible number of variable IDs returned is given by the predefined constant MAX_NC_VARS. If this parameter is given as `(int *) 0', no vector will be returned so no space to hold the record variable IDs needs to be declared or allocated.

rsizes
Returned vector of nrvars sizes for the record variables in this netCDF file. The size of a record variable is the number of bytes required to hold a record's worth of data, which is the product of the non-record dimensions and the size of data type, in bytes. The caller must allocate enough space for a vector of at least nrvars longs to be returned. The maximum possible number of variable IDs returned is given by the predefined constant MAX_NC_VARS. If this parameter is given as `(int *) 0', no vector will be returned so no space to hold the record variable sizes needs to be declared or allocated.

Here is an example using ncrecinq to find out about the record variables in an existing netCDF file named `foo.nc':

#include "netcdf.h"
   ...
int  ncid;                     /* netCDF ID */
int  nrvars;                   /* number of record variables */
int  rvarids[MAX_NC_VARS];     /* IDs of record variables */
long rvarsizes[MAX_NC_VARS];   /* record sizes of record variables */
   ...
ncid = ncopen ("foo.nc", NC_NOWRITE);
   ...
ncrecinq (ncid, &nrvars, rvarids, rvarsizes);

Go to the previous, next section.