3.11 Create a New Group: nc_def_grp
Create a group. Its location id is returned in the new_ncid pointer.
Usage
int nc_def_grp(int parent_ncid, const char *name, int *new_ncid);
parent_ncid
- The group id of the parent group.
name
- The name of the new group.
new_ncid
- A pointer to an int. The ncid of the new group will be placed there.
Errors
NC_NOERR
- No error.
NC_EBADID
- Bad group id.
NC_ENAMEINUSE
- That name is in use. Group names must be unique within a group, and
must not be the same as any variable or type in the group.
NC_EMAXNAME
- Name exceed max length NC_MAX_NAME.
NC_EBADNAME
- Name contains illegal characters.
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.
NC_EPERM
- Attempt to write to a read-only file.
NC_ENOTINDEFINE
- Not in define mode.
Example
int root_ncid, a1_ncid;
char grpname[] = "assimilation1";
/* Get the ncid of the root group. */
if ((res = nc_inq_ncid(root_ncid, NULL, &root_ncid)))
return res;
/* Create a group. */
if ((res = nc_def_grp(root_ncid, grpname, &a1_ncid)))
return res;