Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 
Previous: What are Groups? Next: CDL Example of Groups Table of contents Frames User guide
2008 Unidata NetCDF Workshop for Developers and Data Providers > Using Groups and the New NetCDF-4 Atomic Types

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

 

Note: the "ncid" integer identifies the file and the group within that file. Each group in the file has a different ID.

Calls to nc_create and nc_open return the ID of the root group of the file.

   /* 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: What are Groups? Next: CDL Example of Groups Table of contents Frames User guide
2008 Unidata NetCDF Workshop for Developers and Data Providers > Using Groups and the New NetCDF-4 Atomic Types

 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community 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