2010-06-03 21:24:43 +08:00
|
|
|
/* This is part of the netCDF package.
|
|
|
|
Copyright 2005 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
|
2017-11-25 19:31:58 +08:00
|
|
|
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.
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2017-11-17 04:03:35 +08:00
|
|
|
Ed Hartnett
|
2010-06-03 21:24:43 +08:00
|
|
|
*/
|
|
|
|
#include <nc_tests.h>
|
2016-10-22 01:17:39 +08:00
|
|
|
#include "err_macros.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
#include <hdf5.h>
|
|
|
|
|
2017-11-25 20:19:11 +08:00
|
|
|
#define FILE_NAME "tst_netcdf4_c0.nc"
|
2010-06-03 21:24:43 +08:00
|
|
|
#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];
|
|
|
|
|
2016-10-22 01:17:39 +08:00
|
|
|
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR;
|
2010-06-03 21:24:43 +08:00
|
|
|
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. */
|
2013-01-24 01:45:29 +08:00
|
|
|
if (H5Gget_objtype_by_idx(grpid, i) < 0) ERR;
|
2010-06-03 21:24:43 +08:00
|
|
|
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;
|
|
|
|
}
|