File: tst_h_rdc0.c

package info (click to toggle)
netcdf-parallel 1%3A4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 105,352 kB
  • sloc: ansic: 229,114; sh: 11,180; yacc: 2,561; makefile: 1,390; lex: 1,173; xml: 173; awk: 2
file content (48 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* This is part of the netCDF package.
   Copyright 2018 University Corporation for Atmospheric Research/Unidata
   See COPYRIGHT file for conditions of use.

   Use HDF5 to read c0.nc, a file created by ncdump. This check was
   added to detect a problem in the early HDF5 1.8.0 releases. This
   program is called from the test script tst_netcdf4.sh, which uses
   ncgen to create the test file c0_tst_netcdf4.nc, which this program
   reads with HDF5.

   Ed Hartnett
*/
#include <nc_tests.h>
#include "err_macros.h"
#include <hdf5.h>

#define FILE_NAME "tst_netcdf4_c0.nc"
#define MAX_NAME 1024

int
main()
{
   printf("\n*** Checking HDF5 file c0.nc.\n");
   printf("*** Checking HDF5 objcts...");
   {
      hid_t fileid, grpid;
      hsize_t num_obj, i;
      char obj_name[MAX_NAME];

      if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR;
      if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;

      /* Find the variables. Read their metadata and attributes. */
      if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
      for (i=0; i<num_obj; i++)
      {
	 /* Get the class (i.e. group, dataset, etc.), and the name of
	  * the object. */
	 if (H5Gget_objtype_by_idx(grpid, i) < 0) ERR;
	 if (H5Gget_objname_by_idx(grpid, i, obj_name, MAX_NAME) < 0) ERR;
      }

      if (H5Gclose(grpid) < 0 ||
	  H5Fclose(fileid) < 0) ERR;
   }
   SUMMARIZE_ERR;
   FINAL_RESULTS;
}