Previous: Automatic enddef and redef in NetCDF-4 Next: Using NetCDF-4 Features, Part 2 Table of contents Frames User guide
2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 1

12.11 Multiple Unlimited Dimensions in NetCDF-4
It is possible to have more than one unlimited dimension in a netCDF-4/HDF5 file.

 

      /* Create a file with two unlimied dims and nothing else. */
      if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
      if (nc_def_dim(ncid, REMUS, NC_UNLIMITED, &dimid[0])) ERR;
      if (nc_def_dim(ncid, ROMULUS, NC_UNLIMITED, &dimid[1])) ERR;

      /* Check it out before the enddef. */
      if (nc_inq_dim(ncid, dimid[0], name_in, &len_in)) ERR;
      if (len_in != NC_UNLIMITED || strcmp(name_in, REMUS)) ERR;
      if (nc_inq_dim(ncid, dimid[1], name_in, &len_in)) ERR;
      if (len_in != NC_UNLIMITED || strcmp(name_in, ROMULUS)) ERR;
      if (nc_inq_dimids(ncid, &ndims_in, dimids_in, 0)) ERR;
      if (ndims_in != 2 || dimids_in[0] != 0 || dimids_in[1] != 1) ERR;
      if (nc_inq_unlimdim(ncid, &unlimdimid_in[0])) ERR;
      if (unlimdimid_in[0] != 1) ERR;
      if (nc_inq_unlimdims(ncid, &nunlimdims_in, unlimdimid_in)) ERR;
      if (nunlimdims_in != 2 || unlimdimid_in[0] != 1 || unlimdimid_in[1] != 0) ERR;
      
      /* Automatically enddef and close. */
      if (nc_close(ncid)) ERR;

 


Previous: Automatic enddef and redef in NetCDF-4 Next: Using NetCDF-4 Features, Part 2 Table of contents Frames User guide
2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 1