Previous: Groups and User Defined Types in NetCDF-4 Next: Using User Defined Types Table of contents Frames User guide
2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 2

13.1 Using Groups
NetCDF-4 files can organize variables, dimensions, and attributes in hierarchical groups.

 

This example, from libsrc4/tst_grps.c, shows how groups may be nested.

   /* Create a file with some nested groups in it, suitable
    * to storing information about the Tudor dynasty of England. */
   if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
   if (nc_def_grp(ncid, HENRY_VII, &henry_vii_id)) ERR;
   if (nc_def_grp(henry_vii_id, MARGARET, &margaret_id)) ERR;
   if (nc_def_grp(margaret_id, JAMES_V_OF_SCOTLAND, &james_v_of_scotland_id)) ERR;
   if (nc_def_grp(james_v_of_scotland_id, MARY_I_OF_SCOTLAND, &mary_i_of_scotland_id)) ERR;
   if (nc_def_grp(mary_i_of_scotland_id, JAMES_VI_OF_SCOTLAND_AND_I_OF_ENGLAND, &james_i_of_england_id)) ERR;

   if (nc_inq_grp_ncid(ncid, HENRY_VII, &grp_ncid)) ERR;
   if (nc_inq_grps(ncid, &num_grps, NULL)) ERR;
   if (num_grps != 1) ERR;
   if (nc_inq_grps(ncid, NULL, grpid_in)) ERR;
   if (nc_inq_grpname(grpid_in[0], name_in)) ERR;
   if (strcmp(name_in, HENRY_VII)) ERR;
   if (grpid_in[0] != grp_ncid) ERR;

 


Previous: Groups and User Defined Types in NetCDF-4 Next: Using User Defined Types Table of contents Frames User guide
2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 2