Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Next: , Previous: nc_inq_ncid, Up: Groups



3.2 Get a List of Groups in a Group: nc_inq_grps

Given a location id, return the number of groups it contains, and an array of their ncids.

Usage

     int nc_inq_grps(int ncid, int *numgrps, int *ncids);
ncid
The group id for this operation.
numgrps
Pointer to an int which will get number of groups in this group. If NULL, it's ignored.
ncids
Pointer to a already allocated array of ints which will receive the ids of all the groups in this group. If NULL, it's ignored. Call this function with NULL for ncids parameter to find out how many groups there are.

Errors

NC_NOERR
No error.
NC_EBADID
Bad group id.
NC_ENOTNC4
Attempting a netCDF-4 operation on a netCDF-3 file. NetCDF-4 operations can only be performed on files defined with a create mode which includes flag HDF5. (see nc_open).
NC_ESTRICTNC3
This file was created with the strict netcdf-3 flag, therefore netcdf-4 operations are not allowed. (see nc_open).
NC_EHDFERR
An error was reported by the HDF5 layer.

Example

        int root_ncid, numgrps;
        int *ncids;
        char file[] = "nc4_test.nc";
     
        /* Open the file. */
        if ((res = nc_open(file, NC_NOWRITE, &root_ncid)))
           return res;
     
        /* Get a list of ncids for the root group. (That is, find out of
           there are any groups already defined. */
        if ((res = nc_inq_grps(root_ncid, &numgrps, NULL)))
           return res;
        ncids = malloc(sizeof(int) * numgrps);
        if ((res = nc_inq_grps(root_ncid, NULL, ncids)))
           return res;
 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Office of Programs University Corporation for Atmospheric Research (UCAR)   Unidata is a member of the UCAR Office of Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690