Next: , Previous: nc_inq_grpname_len, Up: Groups


3.8 Find a Group's Parent: nc_inq_grp_parent

Given ncid, find the ncid of the parent group.

When used with the root group, this function returns the NC_ENOGRP error (since the root group has no parent.)

Usage

     int nc_inq_grp_parent(int ncid, int *parent_ncid);
ncid
The group id.
parent_ncid
Pointer to an int. The ncid of the group will be copied there.

Errors

NC_NOERR
No error.
NC_EBADID
Bad group id.
NC_ENOGRP
No parent group found (i.e. this is the root group).
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

        if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
        if (nc_def_grp(ncid, HENRY_VII, &henry_vii_id)) ERR;
     
        if (nc_inq_grp_parent(henry_vii_id, &parent_ncid)) ERR;
        if (parent_ncid != ncid) ERR;
        if (nc_close(ncid)) ERR;