mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-12 18:10:24 +08:00
changes in response to user feedback to rc1, plus cleaned up H5 test dependancy
This commit is contained in:
parent
e5c8e924e2
commit
0259975e26
@ -70,6 +70,7 @@ lib_LTLIBRARIES = libnetcdf_c++.la
|
||||
libnetcdf_c___la_SOURCES = netcdf.cpp ncvalues.cpp
|
||||
libnetcdf_c___la_LDFLAGS = -version-number 4:1:0
|
||||
libnetcdf_c___la_CPPFLAGS = ${AM_CPPFLAGS}
|
||||
libnetcdf_c__4_la_LIBADD = $(top_builddir)/libsrc4/libnetcdf.la
|
||||
|
||||
# If we are building the dll (under MinGW) then set the correct flags.
|
||||
if BUILD_DLL
|
||||
|
@ -7,7 +7,6 @@
|
||||
# only use HDF5; these tests don't use netCDF at all.
|
||||
#
|
||||
# If one of these tests fails, then netCDF-4 will not work correctly.
|
||||
#
|
||||
|
||||
# Set AM_CPPFLAGS and AM_LDFLAGS based on user choices.
|
||||
include $(top_srcdir)/lib_flags.am
|
||||
@ -21,6 +20,11 @@ tst_h_opaques tst_h_strings tst_h_strings1 tst_h_strings2 tst_h_ints \
|
||||
tst_h_dimscales tst_h_dimscales1 tst_h_dimscales2 tst_h_dimscales3 \
|
||||
tst_h_enums
|
||||
|
||||
# If benchmarks were turned on, build and run a bunch more tests.
|
||||
if BUILD_BENCHMARKS
|
||||
H5TESTS += tst_h_mem
|
||||
endif # BUILD_BENCHMARKS
|
||||
|
||||
# List of tests to compile.
|
||||
check_PROGRAMS = $(H5TESTS)
|
||||
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
This file creates the same file as file tst_xplatform2_3 (created
|
||||
by tst_xplatform2.c).
|
||||
|
||||
$Id: tst_h_atts3.c,v 1.11 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define MY_CHUNK_CACHE_SIZE 32000000
|
||||
#define STR_LEN 255
|
||||
|
||||
/* The file we create. */
|
||||
#define FILE_NAME "tst_h_atts3.h5"
|
||||
@ -47,7 +47,7 @@ main()
|
||||
hid_t file_typeid2, native_typeid2;
|
||||
hsize_t num_obj;
|
||||
H5O_info_t obj_info;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
hsize_t dims[1] = {ATT_LEN}; /* netcdf attributes always 1-D. */
|
||||
struct s1
|
||||
{
|
||||
@ -56,7 +56,7 @@ main()
|
||||
};
|
||||
struct s3
|
||||
{
|
||||
nc_vlen_t data[NUM_VL];
|
||||
hvl_t data[NUM_VL];
|
||||
};
|
||||
/* cvc stands for "Compound with Vlen of Compound." */
|
||||
struct s3 cvc_out[ATT_LEN];
|
||||
@ -68,8 +68,7 @@ main()
|
||||
for (j = 0; j < NUM_VL; j++)
|
||||
{
|
||||
cvc_out[i].data[j].len = i + 1;
|
||||
if (!(cvc_out[i].data[j].p = calloc(sizeof(struct s1), cvc_out[i].data[j].len)))
|
||||
return NC_ENOMEM;
|
||||
if (!(cvc_out[i].data[j].p = calloc(sizeof(struct s1), cvc_out[i].data[j].len))) ERR;
|
||||
for (k = 0; k < cvc_out[i].data[j].len; k++)
|
||||
{
|
||||
((struct s1 *)cvc_out[i].data[j].p)[k].x = 42.42;
|
||||
@ -152,7 +151,7 @@ main()
|
||||
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
|
||||
i, &obj_info, H5P_DEFAULT) < 0) ERR;
|
||||
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
|
||||
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR;
|
||||
obj_name, STR_LEN + 1, H5P_DEFAULT) < 0) ERR;
|
||||
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR;
|
||||
|
||||
/* Get the typeid and native typeid. */
|
||||
@ -201,11 +200,11 @@ main()
|
||||
hid_t file_typeid2, native_typeid2;
|
||||
hsize_t num_obj;
|
||||
H5O_info_t obj_info;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
hsize_t dims[1] = {ATT_LEN}; /* netcdf attributes always 1-D. */
|
||||
|
||||
/* vc stands for "Vlen of Compound." */
|
||||
nc_vlen_t vc_out[ATT_LEN];
|
||||
hvl_t vc_out[ATT_LEN];
|
||||
int i, k;
|
||||
|
||||
/* Create some output data: an array of vlen (length ATT_LEN) of
|
||||
@ -213,8 +212,7 @@ main()
|
||||
for (i = 0; i < ATT_LEN; i++)
|
||||
{
|
||||
vc_out[i].len = i + 1;
|
||||
if (!(vc_out[i].p = calloc(sizeof(int), vc_out[i].len)))
|
||||
return NC_ENOMEM;
|
||||
if (!(vc_out[i].p = calloc(sizeof(int), vc_out[i].len))) ERR;
|
||||
for (k = 0; k < vc_out[i].len; k++)
|
||||
((int *)vc_out[i].p)[k] = 42;
|
||||
}
|
||||
@ -272,7 +270,7 @@ main()
|
||||
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
|
||||
i, &obj_info, H5P_DEFAULT) < 0) ERR;
|
||||
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
|
||||
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR;
|
||||
obj_name, STR_LEN + 1, H5P_DEFAULT) < 0) ERR;
|
||||
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR;
|
||||
|
||||
/* Get the typeid and native typeid. */
|
||||
|
@ -11,10 +11,12 @@
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define MY_CHUNK_CACHE_SIZE 32000000
|
||||
#define STR_LEN 255
|
||||
|
||||
/* The file we create. */
|
||||
#define FILE_NAME "tst_h_atts4.h5"
|
||||
@ -48,7 +50,7 @@ main()
|
||||
hid_t file_typeid2, native_typeid2;
|
||||
hsize_t num_obj;
|
||||
H5O_info_t obj_info;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
hsize_t dims[1] = {ATT_LEN}; /* netcdf attributes always 1-D. */
|
||||
struct s1
|
||||
{
|
||||
@ -57,18 +59,16 @@ main()
|
||||
};
|
||||
|
||||
/* vc stands for "Vlen of Compound." */
|
||||
nc_vlen_t *vc_out;
|
||||
hvl_t *vc_out;
|
||||
int i, k;
|
||||
|
||||
/* Create some output data: an array of vlen (length ATT_LEN) of
|
||||
* struct s1. */
|
||||
if (!(vc_out = calloc(sizeof(nc_vlen_t), ATT_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(vc_out = calloc(sizeof(hvl_t), ATT_LEN))) ERR;
|
||||
for (i = 0; i < ATT_LEN; i++)
|
||||
{
|
||||
vc_out[i].len = i + 1;
|
||||
if (!(vc_out[i].p = calloc(sizeof(struct s1), vc_out[i].len)))
|
||||
return NC_ENOMEM;
|
||||
if (!(vc_out[i].p = calloc(sizeof(struct s1), vc_out[i].len))) ERR;
|
||||
for (k = 0; k < vc_out[i].len; k++)
|
||||
{
|
||||
((struct s1 *)vc_out[i].p)[k].x = 42.42;
|
||||
@ -142,7 +142,7 @@ main()
|
||||
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
|
||||
i, &obj_info, H5P_DEFAULT) < 0) ERR;
|
||||
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
|
||||
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR;
|
||||
obj_name, STR_LEN + 1, H5P_DEFAULT) < 0) ERR;
|
||||
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR;
|
||||
|
||||
/* Get the typeid and native typeid. */
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
$Id: tst_h_compounds.c,v 1.25 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_compounds.h5"
|
||||
@ -22,6 +22,7 @@
|
||||
#define LIQUOR "The_Hard_Stuff"
|
||||
#define COMPOUND_NAME "Booze_Index"
|
||||
#define ARRAY_LEN 5
|
||||
#define STR_LEN 255
|
||||
|
||||
int
|
||||
main()
|
||||
@ -40,12 +41,10 @@ main()
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM1_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM1_LEN))) ERR;
|
||||
memcpy((void *)data2, (void *)dummy, sizeof(struct s2) * DIM1_LEN);
|
||||
free(dummy);
|
||||
if (!(dummy = calloc(sizeof(struct s1), DIM1_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct s1), DIM1_LEN))) ERR;
|
||||
memcpy((void *)data2, (void *)dummy, sizeof(struct s1) * DIM1_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -100,7 +99,7 @@ main()
|
||||
if (H5Tget_class(typeid) != H5T_COMPOUND) ERR;
|
||||
if (H5Tget_nmembers(typeid) != 2) ERR;
|
||||
/* This doesn't work because all I have is a reference to the type!
|
||||
if (H5Iget_name(typeid, type_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(typeid, type_name, STR_LEN) < 0) ERR;
|
||||
if (strcmp(type_name, COMPOUND_NAME)) ERR;*/
|
||||
|
||||
/* Release all resources. */
|
||||
@ -158,7 +157,7 @@ main()
|
||||
{
|
||||
hsize_t num_obj;
|
||||
int i, obj_type;
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
htri_t equal;
|
||||
|
||||
|
||||
@ -168,7 +167,7 @@ main()
|
||||
if (H5Gget_num_objs(osmonds_grpid, &num_obj) < 0) ERR;
|
||||
for (i=0; i<num_obj; i++)
|
||||
{
|
||||
if (H5Gget_objname_by_idx(osmonds_grpid, i, name, NC_MAX_NAME+1) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(osmonds_grpid, i, name, STR_LEN+1) < 0) ERR;
|
||||
if ((obj_type = H5Gget_objtype_by_idx(osmonds_grpid, i)) < 0) ERR;
|
||||
switch(obj_type)
|
||||
{
|
||||
@ -254,7 +253,7 @@ main()
|
||||
if (H5Tget_class(typeid) != H5T_COMPOUND) ERR;
|
||||
if (H5Tget_nmembers(typeid) != 2) ERR;
|
||||
/* This doesn't work because all I have is a reference to the type!
|
||||
if (H5Iget_name(typeid, type_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(typeid, type_name, STR_LEN) < 0) ERR;
|
||||
if (strcmp(type_name, COMPOUND_NAME)) ERR;*/
|
||||
|
||||
/* Release all resources. */
|
||||
@ -289,14 +288,13 @@ main()
|
||||
} obs_t ;
|
||||
obs_t obsdata[DIM6_LEN];
|
||||
obs_t obsdata_in[DIM6_LEN], obsdata2_in[DIM6_LEN];
|
||||
char file_in[NC_MAX_NAME * 2];
|
||||
char file_in[STR_LEN * 2];
|
||||
char *dummy;
|
||||
size_t size_in;
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct obs_t), DIM6_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct obs_t), DIM6_LEN))) ERR;
|
||||
memcpy((void *)obsdata, (void *)dummy, sizeof(struct obs_t) * DIM6_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -431,7 +429,7 @@ main()
|
||||
{
|
||||
int starfleet_id;
|
||||
struct s1 svc_rec;
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
float max_temp, min_temp; /* temperature range */
|
||||
double percent_transporter_errosion;
|
||||
};
|
||||
@ -444,8 +442,7 @@ main()
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct hr_rec), DIM1_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct hr_rec), DIM1_LEN))) ERR;
|
||||
memcpy((void *)hr_data_out, (void *)dummy, sizeof(struct hr_rec) * DIM1_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -475,7 +472,7 @@ main()
|
||||
if (H5Tinsert(typeid, "starfleet_id", HOFFSET(struct hr_rec, starfleet_id), H5T_NATIVE_INT) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "svc_rec", HOFFSET(struct hr_rec, svc_rec), typeid_inner) < 0) ERR;
|
||||
if ((array1_tid = H5Tcopy(H5T_C_S1)) < 0) ERR;
|
||||
if (H5Tset_size(array1_tid, NC_MAX_NAME + 1) < 0) ERR;
|
||||
if (H5Tset_size(array1_tid, STR_LEN + 1) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "name", HOFFSET(struct hr_rec, name), array1_tid) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "max_temp", HOFFSET(struct hr_rec, max_temp), H5T_NATIVE_FLOAT) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "min_temp", HOFFSET(struct hr_rec, min_temp), H5T_NATIVE_FLOAT) < 0) ERR;
|
||||
@ -544,7 +541,7 @@ main()
|
||||
{
|
||||
int starfleet_id;
|
||||
struct s1 svc_rec;
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
float max_temp, min_temp; /* temperature range */
|
||||
double percent_transporter_errosion;
|
||||
};
|
||||
@ -579,7 +576,7 @@ main()
|
||||
if ((typeid = H5Tcreate(H5T_COMPOUND, sizeof(struct hr_rec))) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "starfleet_id", HOFFSET(struct hr_rec, starfleet_id), H5T_NATIVE_INT) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "svc_rec", HOFFSET(struct hr_rec, svc_rec), typeid_inner) < 0) ERR;
|
||||
dims[0] = NC_MAX_NAME + 1;
|
||||
dims[0] = STR_LEN + 1;
|
||||
if ((str_tid = H5Tcopy(H5T_C_S1)) < 0) ERR;
|
||||
if (H5Tset_strpad(str_tid, H5T_STR_NULLTERM) < 0) ERR;
|
||||
if ((array1_tid = H5Tarray_create2(str_tid, 1, dims)) < 0) ERR;
|
||||
@ -652,7 +649,7 @@ main()
|
||||
{
|
||||
int starfleet_id;
|
||||
struct s1 svc_rec;
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
float max_temp, min_temp; /* temperature range */
|
||||
double percent_transporter_errosion;
|
||||
};
|
||||
@ -688,7 +685,7 @@ main()
|
||||
if (H5Tinsert(typeid, "starfleet_id", HOFFSET(struct hr_rec, starfleet_id), H5T_NATIVE_INT) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "svc_rec", HOFFSET(struct hr_rec, svc_rec), typeid_inner) < 0) ERR;
|
||||
if ((array1_tid = H5Tcopy(H5T_C_S1)) < 0) ERR;
|
||||
if (H5Tset_size(array1_tid, NC_MAX_NAME + 1) < 0) ERR;
|
||||
if (H5Tset_size(array1_tid, STR_LEN + 1) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "name", HOFFSET(struct hr_rec, name), array1_tid) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "max_temp", HOFFSET(struct hr_rec, max_temp), H5T_NATIVE_FLOAT) < 0) ERR;
|
||||
if (H5Tinsert(typeid, "min_temp", HOFFSET(struct hr_rec, min_temp), H5T_NATIVE_FLOAT) < 0) ERR;
|
||||
@ -747,13 +744,13 @@ main()
|
||||
#define DATASET_NAME "Enterprise"
|
||||
struct hr_rec
|
||||
{
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
float max_temp;
|
||||
};
|
||||
struct hr_rec hr_data_out[DIM1_LEN], hr_data_in[DIM1_LEN];
|
||||
|
||||
hid_t fileid, grpid, typeid, spaceid, array1_tid, datasetid, str_tid;
|
||||
hsize_t dims[1] = {NC_MAX_NAME + 1};
|
||||
hsize_t dims[1] = {STR_LEN + 1};
|
||||
int i;
|
||||
|
||||
/* Create some phony data. */
|
||||
@ -825,20 +822,19 @@ main()
|
||||
#define ATT_NAME "HR_Records"
|
||||
struct hr_rec
|
||||
{
|
||||
char name[NC_MAX_NAME + 1];
|
||||
char name[STR_LEN + 1];
|
||||
float max_temp;
|
||||
};
|
||||
struct hr_rec hr_data_out[DIM2_LEN], hr_data_in[DIM2_LEN];
|
||||
|
||||
hid_t fileid, grpid, typeid, spaceid, array1_tid, attid, str_tid;
|
||||
hsize_t dims[1] = {NC_MAX_NAME + 1};
|
||||
hsize_t dims[1] = {STR_LEN + 1};
|
||||
char *dummy;
|
||||
int i;
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct hr_rec), DIM2_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct hr_rec), DIM2_LEN))) ERR;
|
||||
memcpy((void *)hr_data_out, (void *)dummy, sizeof(struct hr_rec) * DIM2_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -910,20 +906,20 @@ main()
|
||||
#define DISC_ATT_NAME "Discovery"
|
||||
struct s1
|
||||
{
|
||||
unsigned char x[NC_MAX_NAME + 1];
|
||||
unsigned char x[STR_LEN + 1];
|
||||
float y;
|
||||
};
|
||||
struct s1 data_out[DISC_DIM1_LEN], data_in[DISC_DIM1_LEN];
|
||||
|
||||
hid_t fileid, grpid, typeid, spaceid, array1_tid, attid;
|
||||
hid_t fcpl_id, fapl_id;
|
||||
hsize_t dims[1] = {NC_MAX_NAME + 1};
|
||||
hsize_t dims[1] = {STR_LEN + 1};
|
||||
int i, j;
|
||||
|
||||
/* Create some data. */
|
||||
for (i = 0; i < DISC_DIM1_LEN; i++)
|
||||
{
|
||||
for (j = 0; j < NC_MAX_NAME + 1; j++)
|
||||
for (j = 0; j < STR_LEN + 1; j++)
|
||||
data_out[i].x[j] = 4;
|
||||
data_out[i].y = 99.99;
|
||||
}
|
||||
@ -980,7 +976,7 @@ main()
|
||||
/* Check the data. */
|
||||
for (i = 0; i < DISC_DIM1_LEN; i++)
|
||||
{
|
||||
for (j = 0; j < NC_MAX_NAME + 1; j++)
|
||||
for (j = 0; j < STR_LEN + 1; j++)
|
||||
if (data_in[i].x[j] != data_out[i].x[j]) ERR_RET;
|
||||
if (data_in[i].y != data_out[i].y) ERR;
|
||||
}
|
||||
@ -1021,8 +1017,7 @@ main()
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN))) ERR;
|
||||
memcpy((void *)data_out, (void *)dummy, sizeof(struct s2) * DIM_CMP_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -1124,8 +1119,7 @@ main()
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN))) ERR;
|
||||
memcpy((void *)data_out, (void *)dummy, sizeof(struct s2) * DIM_CMP_LEN);
|
||||
free(dummy);
|
||||
|
||||
|
@ -10,11 +10,13 @@
|
||||
|
||||
$Id: tst_h_compounds2.c,v 1.17 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_compounds2.h5"
|
||||
#define REF_FILE_IN "ref_tst_h_compounds2.h5"
|
||||
#define STR_LEN 255
|
||||
|
||||
int
|
||||
main()
|
||||
@ -45,18 +47,17 @@ main()
|
||||
hid_t att_typeid, att_native_typeid;
|
||||
hsize_t dims[1];
|
||||
hsize_t num_obj, i_obj;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
H5O_info_t obj_info;
|
||||
hid_t fapl_id, fcpl_id;
|
||||
htri_t equal;
|
||||
char file_in[NC_MAX_NAME * 2];
|
||||
char file_in[STR_LEN * 2];
|
||||
char *dummy;
|
||||
int i;
|
||||
|
||||
/* REALLY initialize the data (even the gaps in the structs). This
|
||||
* is only needed to pass valgrind. */
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN)))
|
||||
return NC_ENOMEM;
|
||||
if (!(dummy = calloc(sizeof(struct s2), DIM_CMP_LEN))) ERR;
|
||||
memcpy((void *)data_out, (void *)dummy, sizeof(struct s2) * DIM_CMP_LEN);
|
||||
free(dummy);
|
||||
|
||||
@ -133,7 +134,7 @@ main()
|
||||
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
|
||||
i_obj, &obj_info, H5P_DEFAULT) < 0) ERR;
|
||||
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
|
||||
i_obj, obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR;
|
||||
i_obj, obj_name, STR_LEN + 1, H5P_DEFAULT) < 0) ERR;
|
||||
|
||||
/* Deal with groups and datasets. */
|
||||
if (obj_info.type == H5O_TYPE_NAMED_DATATYPE)
|
||||
@ -196,7 +197,7 @@ main()
|
||||
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i_obj, &obj_info,
|
||||
H5P_DEFAULT) < 0) ERR;
|
||||
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, i_obj, obj_name,
|
||||
NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR;
|
||||
STR_LEN + 1, H5P_DEFAULT) < 0) ERR;
|
||||
|
||||
/* Deal with groups and datasets. */
|
||||
if (obj_info.type == H5O_TYPE_NAMED_DATATYPE)
|
||||
|
@ -8,22 +8,23 @@
|
||||
|
||||
$Id: tst_h_dimscales.c,v 1.15 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
#define FILE_NAME "tst_h_dimscales.h5"
|
||||
|
||||
#define STR_LEN 255
|
||||
#define MAX_DIMS 255
|
||||
|
||||
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
|
||||
void *visitor_data)
|
||||
{
|
||||
char name1[NC_MAX_NAME], name2[NC_MAX_NAME];
|
||||
char name1[STR_LEN], name2[STR_LEN];
|
||||
H5G_stat_t statbuf;
|
||||
|
||||
(*(hid_t *)visitor_data) = dsid;
|
||||
if (H5Iget_name(did, name1, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(dsid, name2, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
|
||||
if (H5Iget_name(dsid, name2, STR_LEN) < 0) ERR;
|
||||
/* printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n", */
|
||||
/* did, dim, dsid, name1); */
|
||||
/* printf("name of dsid: %s\n", name2); */
|
||||
@ -41,10 +42,10 @@ rec_scan_group(hid_t grpid)
|
||||
hid_t spaceid, datasetid = 0, child_grpid;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t dims[NC_MAX_DIMS], max_dims[NC_MAX_DIMS];
|
||||
hsize_t dims[MAX_DIMS], max_dims[MAX_DIMS];
|
||||
int ndims, d;
|
||||
|
||||
/* Loop through datasets to find variables. */
|
||||
@ -54,7 +55,7 @@ rec_scan_group(hid_t grpid)
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
|
||||
obj_class, obj_name);*/
|
||||
|
||||
@ -73,7 +74,7 @@ rec_scan_group(hid_t grpid)
|
||||
/* Get the dimensions of this dataset. */
|
||||
if ((spaceid = H5Dget_space(datasetid)) < 0) ERR;
|
||||
if ((ndims = H5Sget_simple_extent_ndims(spaceid)) < 0) ERR;
|
||||
if (ndims > NC_MAX_DIMS) ERR;
|
||||
if (ndims > MAX_DIMS) ERR;
|
||||
if (H5Sget_simple_extent_dims(spaceid, dims, max_dims) < 0) ERR;
|
||||
|
||||
/* Is this a dimscale? */
|
||||
@ -191,7 +192,7 @@ main()
|
||||
hid_t fileid, grpid, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
|
||||
@ -208,7 +209,7 @@ main()
|
||||
* of a variable. This type might be better called "class" or
|
||||
* "type of type" */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", obj_class, obj_name);*/
|
||||
|
||||
/* Deal with groups and datasets. */
|
||||
@ -230,12 +231,12 @@ main()
|
||||
if (is_scale && strcmp(obj_name, DIMSCALE_NAME)) ERR;
|
||||
if (is_scale)
|
||||
{
|
||||
char nom_de_quincey[NC_MAX_NAME+1];
|
||||
char nom_de_quincey[STR_LEN+1];
|
||||
|
||||
/* A dimscale comes with a NAME attribute, in
|
||||
* addition to its real name. */
|
||||
if (H5DSget_scale_name(datasetid, nom_de_quincey,
|
||||
NC_MAX_NAME) < 0) ERR;
|
||||
STR_LEN) < 0) ERR;
|
||||
if (strcmp(nom_de_quincey, NAME_ATTRIBUTE)) ERR;
|
||||
|
||||
/*printf("found scale %s, NAME %s\n", obj_name, nom_de_quincey);*/
|
||||
@ -243,7 +244,7 @@ main()
|
||||
}
|
||||
else
|
||||
{
|
||||
char label[NC_MAX_NAME+1];
|
||||
char label[STR_LEN+1];
|
||||
|
||||
/* Here's how to get the number of scales attached
|
||||
* to the dataset. I would think that this would
|
||||
@ -258,7 +259,7 @@ main()
|
||||
/* There's also a label for dimension 0 of var1. */
|
||||
if (strcmp(obj_name, VAR1_NAME) == 0)
|
||||
{
|
||||
if (H5DSget_label(datasetid, 0, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
|
||||
if (strcmp(label, FIFTIES_SONG)) ERR;
|
||||
}
|
||||
}
|
||||
@ -288,7 +289,7 @@ main()
|
||||
hid_t var1_datasetid[NUM_DATASETS];
|
||||
hsize_t dims[2] = {DIM1_LEN, DIM2_LEN};
|
||||
hsize_t dimscale_dims[1] = {DIM1_LEN};
|
||||
char var_name[NC_MAX_NAME + 1];
|
||||
char var_name[STR_LEN + 1];
|
||||
int v;
|
||||
|
||||
/* Open file and create group. */
|
||||
@ -368,7 +369,7 @@ main()
|
||||
hid_t fileid, grpid, spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t dims[1], maxdims[1];
|
||||
@ -384,7 +385,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", obj_class, obj_name);*/
|
||||
|
||||
/* Deal with groups and datasets. */
|
||||
@ -414,17 +415,17 @@ main()
|
||||
if (is_scale && strcmp(obj_name, DIMSCALE_NAME)) ERR;
|
||||
if (is_scale)
|
||||
{
|
||||
char nom_de_quincey[NC_MAX_NAME+1];
|
||||
char nom_de_quincey[STR_LEN+1];
|
||||
|
||||
/* A dimscale comes with a NAME attribute, in
|
||||
* addition to its real name. */
|
||||
if (H5DSget_scale_name(datasetid, nom_de_quincey, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_scale_name(datasetid, nom_de_quincey, STR_LEN) < 0) ERR;
|
||||
/*printf("found scale %s, NAME %s\n", obj_name, nom_de_quincey);*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
char label[NC_MAX_NAME+1];
|
||||
char label[STR_LEN+1];
|
||||
int visitor_data = 0;
|
||||
|
||||
/* Here's how to get the number of scales attached
|
||||
@ -437,7 +438,7 @@ main()
|
||||
&visitor_data) < 0) ERR;
|
||||
|
||||
/* There's also a label for dimension 0. */
|
||||
if (H5DSget_label(datasetid, 0, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
|
||||
|
||||
/*printf("found non-scale dataset %s, label %s\n", obj_name, label);*/
|
||||
}
|
||||
@ -559,7 +560,7 @@ main()
|
||||
hid_t fileid, grpid, spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t dims[NDIMS], max_dims[NDIMS];
|
||||
@ -576,7 +577,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", obj_class, obj_name);*/
|
||||
|
||||
/* Deal with groups and datasets. */
|
||||
@ -597,12 +598,12 @@ main()
|
||||
if ((is_scale = H5DSis_scale(datasetid)) < 0) ERR;
|
||||
if (is_scale)
|
||||
{
|
||||
char nom_de_quincey[NC_MAX_NAME+1];
|
||||
char nom_de_quincey[STR_LEN+1];
|
||||
|
||||
/* A dimscale comes with a NAME attribute, in
|
||||
* addition to its real name. */
|
||||
if (H5DSget_scale_name(datasetid, nom_de_quincey,
|
||||
NC_MAX_NAME) < 0) ERR;
|
||||
STR_LEN) < 0) ERR;
|
||||
/*printf("found scale %s, NAME %s id 0x%x\n", obj_name,
|
||||
nom_de_quincey, datasetid);*/
|
||||
|
||||
@ -615,7 +616,7 @@ main()
|
||||
}
|
||||
else
|
||||
{
|
||||
char label[NC_MAX_NAME+1];
|
||||
char label[STR_LEN+1];
|
||||
int visitor_data = 0;
|
||||
|
||||
/* SHould have these dimensions... */
|
||||
@ -637,11 +638,11 @@ main()
|
||||
/*printf("visitor_data: 0x%x\n", visitor_data);*/
|
||||
|
||||
/* There's also a label for each dimension. */
|
||||
if (H5DSget_label(datasetid, 0, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
|
||||
if (strcmp(label, TIME_NAME)) ERR;
|
||||
if (H5DSget_label(datasetid, 1, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 1, label, STR_LEN) < 0) ERR;
|
||||
if (strcmp(label, LAT_NAME)) ERR;
|
||||
if (H5DSget_label(datasetid, 2, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 2, label, STR_LEN) < 0) ERR;
|
||||
if (strcmp(label, LON_NAME)) ERR;
|
||||
}
|
||||
if (H5Dclose(datasetid) < 0) ERR;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
$Id: tst_h_dimscales1.c,v 1.2 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
but they use HDF5 the same way that netCDF-4 does, so if these
|
||||
tests don't work, than netCDF-4 won't work either.
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#include <ncdimscale.h>
|
||||
@ -18,6 +18,7 @@
|
||||
#define DIM1_LEN 3
|
||||
#define NAME_ATTRIBUTE "dimscale_name_attribute"
|
||||
#define DIMSCALE_LABEL "dimscale_label"
|
||||
#define STR_LEN 255
|
||||
|
||||
/* typedef struct { */
|
||||
/* unsigned long fileno; /\*file number *\/ */
|
||||
@ -27,13 +28,13 @@
|
||||
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
|
||||
void *visitor_data)
|
||||
{
|
||||
char name1[NC_MAX_NAME];
|
||||
char name1[STR_LEN];
|
||||
H5G_stat_t statbuf;
|
||||
HDF5_OBJID_T *objid = visitor_data;
|
||||
|
||||
/* This should get "/var1", the name of the dataset that the scale
|
||||
* is attached to. */
|
||||
if (H5Iget_name(did, name1, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
|
||||
if (strcmp(&name1[1], VAR1_NAME)) ERR;
|
||||
|
||||
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
|
||||
@ -56,11 +57,11 @@ herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
|
||||
|
||||
herr_t alien_visitor2(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
|
||||
{
|
||||
char name1[NC_MAX_NAME];
|
||||
char name1[STR_LEN];
|
||||
H5G_stat_t statbuf;
|
||||
HDF5_OBJID_T *objid = visitor_data;
|
||||
|
||||
if (H5Iget_name(did, name1, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
|
||||
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
|
||||
did, dim, dsid, name1); */
|
||||
|
||||
@ -123,10 +124,10 @@ main()
|
||||
hid_t fileid, spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char dimscale_name[NC_MAX_NAME+1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
char dimscale_name[STR_LEN+1];
|
||||
htri_t is_scale;
|
||||
char label[NC_MAX_NAME+1];
|
||||
char label[STR_LEN+1];
|
||||
int num_scales;
|
||||
hsize_t dims[1], maxdims[1];
|
||||
H5G_stat_t statbuf;
|
||||
@ -142,7 +143,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
|
||||
obj_class, obj_name);*/
|
||||
@ -168,7 +169,7 @@ main()
|
||||
{
|
||||
/* A dimscale comes with a NAME attribute, in
|
||||
* addition to its real name. */
|
||||
if (H5DSget_scale_name(datasetid, dimscale_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_scale_name(datasetid, dimscale_name, STR_LEN) < 0) ERR;
|
||||
if (strcmp(dimscale_name, NAME_ATTRIBUTE)) ERR;
|
||||
|
||||
/* fileno and objno uniquely identify an object and a
|
||||
@ -200,7 +201,7 @@ main()
|
||||
vars_dimscale_obj.objno[1] != dimscale_obj.objno[1]) ERR;
|
||||
|
||||
/* There's also a label for dimension 0. */
|
||||
if (H5DSget_label(datasetid, 0, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
|
||||
|
||||
/*printf("found non-scale dataset %s, label %s\n", obj_name, label);*/
|
||||
}
|
||||
@ -282,7 +283,7 @@ main()
|
||||
hid_t fileid, spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t dims[NDIMS2], maxdims[NDIMS2];
|
||||
@ -301,7 +302,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
|
||||
/* obj_class, obj_name); */
|
||||
@ -393,7 +394,7 @@ main()
|
||||
hid_t spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
H5G_stat_t statbuf;
|
||||
@ -487,7 +488,7 @@ main()
|
||||
/*Get the type (i.e. group, dataset, etc.), and the name of
|
||||
the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/* Deal with object based on its obj_class. */
|
||||
switch(obj_class)
|
||||
@ -695,7 +696,7 @@ main()
|
||||
hid_t spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t maxdims[DIMS_3];
|
||||
@ -788,7 +789,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
|
||||
/* obj_class, obj_name); */
|
||||
@ -886,7 +887,7 @@ main()
|
||||
hid_t spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
htri_t is_scale;
|
||||
int num_scales;
|
||||
hsize_t maxdims[DIMS_3];
|
||||
@ -979,7 +980,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
|
||||
/* obj_class, obj_name); */
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
$Id: tst_h_dimscales3.c,v 1.2 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
#include <hdf5.h>
|
||||
@ -21,6 +21,7 @@
|
||||
#define DIM1_LEN 3
|
||||
#define NAME_ATTRIBUTE "dimscale_name_attribute"
|
||||
#define DIMSCALE_LABEL "dimscale_label"
|
||||
#define STR_LEN 255
|
||||
|
||||
/* typedef struct { */
|
||||
/* unsigned long fileno; /\*file number *\/ */
|
||||
@ -30,13 +31,13 @@
|
||||
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
|
||||
void *visitor_data)
|
||||
{
|
||||
char name1[NC_MAX_NAME];
|
||||
char name1[STR_LEN];
|
||||
H5G_stat_t statbuf;
|
||||
HDF5_OBJID_T *objid = visitor_data;
|
||||
|
||||
/* This should get "/var1", the name of the dataset that the scale
|
||||
* is attached to. */
|
||||
if (H5Iget_name(did, name1, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
|
||||
if (strcmp(&name1[1], VAR1_NAME)) ERR;
|
||||
|
||||
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
|
||||
@ -59,11 +60,11 @@ herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
|
||||
|
||||
herr_t alien_visitor2(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
|
||||
{
|
||||
char name1[NC_MAX_NAME];
|
||||
char name1[STR_LEN];
|
||||
H5G_stat_t statbuf;
|
||||
HDF5_OBJID_T *objid = visitor_data;
|
||||
|
||||
if (H5Iget_name(did, name1, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
|
||||
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
|
||||
did, dim, dsid, name1); */
|
||||
|
||||
@ -122,10 +123,10 @@ main()
|
||||
hid_t fileid, spaceid = 0, datasetid = 0;
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char dimscale_name[NC_MAX_NAME+1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
char dimscale_name[STR_LEN+1];
|
||||
htri_t is_scale;
|
||||
char label[NC_MAX_NAME+1];
|
||||
char label[STR_LEN+1];
|
||||
int num_scales;
|
||||
hsize_t dims[1], maxdims[1];
|
||||
H5G_stat_t statbuf;
|
||||
@ -141,7 +142,7 @@ main()
|
||||
/* Get the type (i.e. group, dataset, etc.), and the name of
|
||||
* the object. */
|
||||
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
|
||||
|
||||
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
|
||||
obj_class, obj_name);*/
|
||||
@ -167,7 +168,7 @@ main()
|
||||
{
|
||||
/* A dimscale comes with a NAME attribute, in
|
||||
* addition to its real name. */
|
||||
if (H5DSget_scale_name(datasetid, dimscale_name, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_scale_name(datasetid, dimscale_name, STR_LEN) < 0) ERR;
|
||||
if (strcmp(dimscale_name, NAME_ATTRIBUTE)) ERR;
|
||||
|
||||
/* fileno and objno uniquely identify an object and a
|
||||
@ -199,7 +200,7 @@ main()
|
||||
vars_dimscale_obj.objno[1] != dimscale_obj.objno[1]) ERR;
|
||||
|
||||
/* There's also a label for dimension 0. */
|
||||
if (H5DSget_label(datasetid, 0, label, NC_MAX_NAME) < 0) ERR;
|
||||
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
|
||||
|
||||
/*printf("found non-scale dataset %s, label %s\n", obj_name, label);*/
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
$Id: tst_h_enums.c,v 1.14 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_enums.h5"
|
||||
@ -15,6 +15,7 @@
|
||||
#define SIZE 9
|
||||
#define GRP_NAME "Browning"
|
||||
#define NUM_VALS 12
|
||||
#define STR_LEN 255
|
||||
|
||||
/* This seems like a good sonnet for enumation:
|
||||
|
||||
@ -48,7 +49,7 @@ main()
|
||||
short data_in[DIM1_LEN];
|
||||
int i;
|
||||
short val[NUM_VALS];
|
||||
char love_how[NUM_VALS][NC_MAX_NAME + 1] = {"Depth", "Bredth",
|
||||
char love_how[NUM_VALS][STR_LEN + 1] = {"Depth", "Bredth",
|
||||
"Height", "Level",
|
||||
"Freely", "Purely",
|
||||
"Passionately", "Lost",
|
||||
@ -149,7 +150,7 @@ main()
|
||||
short data_in[DIM1_LEN];
|
||||
int i;
|
||||
short val[NUM_LANG];
|
||||
char lang[NUM_LANG][NC_MAX_NAME + 1] = {"C", "Fortran", "C++", "MISSING"};
|
||||
char lang[NUM_LANG][STR_LEN + 1] = {"C", "Fortran", "C++", "MISSING"};
|
||||
enum langs {CLANG=0, Fortran=1, CPP=2, MISSING=255};
|
||||
short the_value, fill_value = MISSING, data_point = CLANG;
|
||||
hsize_t start[1] = {1}, count[1] = {1};
|
||||
|
@ -5,17 +5,15 @@
|
||||
Test HDF5 file code. These are not intended to be exhaustive tests,
|
||||
but they use HDF5 the same way that netCDF-4 does, so if these
|
||||
tests don't work, than netCDF-4 won't work either.
|
||||
|
||||
$Id: tst_h_files.c,v 1.20 2010/02/04 17:17:49 ed Exp $
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
#define FILE_NAME "tst_h_files.h5"
|
||||
#define GRP_NAME "Dectectives"
|
||||
#define STR_LEN 255
|
||||
|
||||
int
|
||||
main()
|
||||
@ -32,7 +30,7 @@ main()
|
||||
unsigned char data[DIM_LEN][OPAQUE_SIZE];
|
||||
hsize_t num_obj, i;
|
||||
int obj_class;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
H5T_class_t class;
|
||||
size_t type_size;
|
||||
int j, k;
|
||||
@ -81,7 +79,7 @@ main()
|
||||
{
|
||||
if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR;
|
||||
if (H5Gget_objname_by_idx(grpid, i, obj_name,
|
||||
NC_MAX_NAME) < 0) ERR;
|
||||
STR_LEN) < 0) ERR;
|
||||
if (obj_class != H5G_TYPE) ERR;
|
||||
if ((typeid = H5Topen(grpid, obj_name)) < 0) ERR;
|
||||
if ((class = H5Tget_class(typeid)) < 0) ERR;
|
||||
@ -239,8 +237,8 @@ main()
|
||||
hsize_t *chunksize, dims[1], maxdims[1], *dimsize, *maxdimsize;
|
||||
hsize_t fdims[NC_MAX_DIMS], fmaxdims[NC_MAX_DIMS];
|
||||
hsize_t start[NC_MAX_DIMS], count[NC_MAX_DIMS];
|
||||
char file_name[NC_MAX_NAME + 1];
|
||||
char dimscale_wo_var[NC_MAX_NAME];
|
||||
char file_name[STR_LEN + 1];
|
||||
char dimscale_wo_var[STR_LEN];
|
||||
void *bufr;
|
||||
void *fillp;
|
||||
|
||||
|
@ -5,12 +5,9 @@
|
||||
Test HDF5 file code. These are not intended to be exhaustive tests,
|
||||
but they use HDF5 the same way that netCDF-4 does, so if these
|
||||
tests don't work, than netCDF-4 won't work either.
|
||||
|
||||
$Id: tst_h_files2.c,v 1.4 2009/05/06 14:50:52 ed Exp $
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
|
@ -5,16 +5,15 @@
|
||||
Test HDF5 file code. These are not intended to be exhaustive tests,
|
||||
but they use HDF5 the same way that netCDF-4 does, so if these
|
||||
tests don't work, than netCDF-4 won't work either.
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
#define FILE_NAME "tst_h_files4.h5"
|
||||
#define STR_LEN 255
|
||||
|
||||
/* Heavy duty test file...*/
|
||||
/*#define FILE_NAME "/machine/downloads/T159_1978110112.nc4"*/
|
||||
|
||||
@ -142,7 +141,7 @@ main()
|
||||
{
|
||||
hid_t fapl_id, fileid, grpid;
|
||||
hsize_t idx = 0;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
hsize_t num_obj;
|
||||
int i;
|
||||
|
||||
@ -173,7 +172,7 @@ main()
|
||||
H5O_info_t obj_info;
|
||||
hsize_t num_obj;
|
||||
ssize_t size;
|
||||
char obj_name[NC_MAX_NAME + 1];
|
||||
char obj_name[STR_LEN + 1];
|
||||
int i;
|
||||
|
||||
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
|
||||
|
@ -3,10 +3,9 @@
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Check out HDF5 groups.
|
||||
|
||||
$Id: tst_h_grps.c,v 1.10 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_grps.h5"
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
Here's a HDF5 sample programs:
|
||||
http://hdf.ncsa.uiuc.edu/training/other-ex5/sample-programs/strings.c
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_ints.h5"
|
||||
|
104
h5_test/tst_h_mem.c
Normal file
104
h5_test/tst_h_mem.c
Normal file
@ -0,0 +1,104 @@
|
||||
/* This is part of the netCDF package. Copyright 2007 University
|
||||
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
|
||||
conditions of use.
|
||||
|
||||
Test HDF5 dataset code, even more. These are not intended to be
|
||||
exhaustive tests, but they use HDF5 the same way that netCDF-4
|
||||
does, so if these tests don't work, than netCDF-4 won't work
|
||||
either.
|
||||
*/
|
||||
|
||||
#include <nc_tests.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
#define FILE_NAME "tst_h_mem.h5"
|
||||
#define STR_LEN 255
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
printf("\n*** Checking HDF5 memory use.\n");
|
||||
printf("*** checking HDF5 memory use writing along unlimited dimension...");
|
||||
{
|
||||
#define NDIMS1 1
|
||||
#define NUM_DATASETS 10000
|
||||
#define CHUNKSIZE 1
|
||||
|
||||
hid_t fapl_id, fcpl_id;
|
||||
hid_t datasetid[NUM_DATASETS];
|
||||
hid_t fileid, grpid, spaceid, plistid;
|
||||
hsize_t chunksize[NDIMS1], dimsize[NDIMS1], maxdimsize[NDIMS1];
|
||||
char var_name[STR_LEN + 1];
|
||||
int v;
|
||||
|
||||
/* Create file, setting latest_format in access propertly list
|
||||
* and H5P_CRT_ORDER_TRACKED in the creation property list. */
|
||||
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
|
||||
if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR;
|
||||
if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) ERR;
|
||||
if (H5Pset_link_creation_order(fcpl_id, H5P_CRT_ORDER_TRACKED|H5P_CRT_ORDER_INDEXED) < 0) ERR;
|
||||
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR;
|
||||
|
||||
/* Open root group. */
|
||||
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
|
||||
|
||||
/* Create 1 D data space with unlimited dimension. */
|
||||
dimsize[0] = 0;
|
||||
maxdimsize[0] = H5S_UNLIMITED;
|
||||
if ((spaceid = H5Screate_simple(NDIMS1, dimsize, maxdimsize)) < 0) ERR;
|
||||
|
||||
/* Create property list. */
|
||||
if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR;
|
||||
|
||||
/* Set up chunksizes. */
|
||||
chunksize[0] = CHUNKSIZE;
|
||||
if (H5Pset_chunk(plistid, NDIMS1, chunksize) < 0)ERR;
|
||||
|
||||
/* Create the variables. */
|
||||
for (v = 0; v < NUM_DATASETS; v++)
|
||||
{
|
||||
sprintf(var_name, "var_%d", v);
|
||||
/* printf("creating var %s\n", var_name);*/
|
||||
if ((datasetid[v] = H5Dcreate(grpid, var_name, H5T_NATIVE_INT,
|
||||
spaceid, plistid)) < 0) ERR_RET;
|
||||
}
|
||||
|
||||
/* Close the datasets. */
|
||||
for (v = 0; v < NUM_DATASETS; v++)
|
||||
if (H5Dclose(datasetid[v]) < 0) ERR_RET;
|
||||
|
||||
/* Close everything. */
|
||||
if (H5Pclose(fapl_id) < 0 ||
|
||||
H5Sclose(spaceid) < 0 ||
|
||||
H5Gclose(grpid) < 0 ||
|
||||
H5Fclose(fileid) < 0)
|
||||
ERR;
|
||||
|
||||
/* Now reopen the file and check. */
|
||||
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
|
||||
if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR;
|
||||
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, fapl_id)) < 0) ERR;
|
||||
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
|
||||
|
||||
/* if ((datasetid = H5Dopen1(grpid, SIMPLE_VAR_NAME)) < 0) ERR; */
|
||||
/* if ((spaceid = H5Dget_space(datasetid)) < 0) */
|
||||
/* if (H5Sget_simple_extent_dims(spaceid, fdims, fmaxdims) > 0) ERR; */
|
||||
/* if (H5Dread(datasetid, H5T_NATIVE_INT, H5S_ALL, */
|
||||
/* spaceid, H5P_DEFAULT, data_in) < 0) ERR; */
|
||||
|
||||
/* /\* Check the data. *\/ */
|
||||
/* for (x = 0; x < NX; x++) */
|
||||
/* for (y = 0; y < NY; y++) */
|
||||
/* if (data_in[x][y] != data_out[x][y]) ERR_RET; */
|
||||
|
||||
if (H5Pclose(fapl_id) < 0 ||
|
||||
/* H5Dclose(datasetid) < 0 ||
|
||||
H5Sclose(spaceid) < 0 ||*/
|
||||
H5Gclose(grpid) < 0 ||
|
||||
H5Fclose(fileid) < 0)
|
||||
ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
}
|
@ -3,10 +3,9 @@
|
||||
conditions of use.
|
||||
|
||||
This program excersizes HDF5 variable length array code.
|
||||
|
||||
$Id: tst_h_opaques.c,v 1.8 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_opaques.h5"
|
||||
|
@ -3,10 +3,9 @@
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Test HDF5 compound types.
|
||||
|
||||
$Id: tst_h_rd_cmp.c,v 1.7 2010/06/01 15:34:51 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_wrt_cmp.h5"
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
Here's a HDF5 sample programs:
|
||||
http://hdf.ncsa.uiuc.edu/training/other-ex5/sample-programs/strings.c
|
||||
|
||||
$Id: tst_h_strings.c,v 1.19 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_strings.h5"
|
||||
@ -64,8 +63,7 @@ main()
|
||||
|
||||
/* Given this type id, how would we know this is a string
|
||||
* attribute? */
|
||||
if ((class = H5Tget_class(typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
if ((class = H5Tget_class(typeid)) < 0) ERR;
|
||||
if (class != H5T_STRING) ERR;
|
||||
if (!(type_size = H5Tget_size(typeid))) ERR;
|
||||
if ((is_str = H5Tis_variable_str(typeid)) < 0) ERR;
|
||||
@ -133,8 +131,7 @@ main()
|
||||
|
||||
/* Given this type id, how would we know this is a string
|
||||
* attribute? */
|
||||
if ((class = H5Tget_class(typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
if ((class = H5Tget_class(typeid)) < 0) ERR;
|
||||
if (class != H5T_STRING) ERR;
|
||||
/* if (!(type_size = H5Tget_size(typeid))) ERR;
|
||||
if ((is_str = H5Tis_variable_str(typeid)) < 0) ERR;*/
|
||||
@ -219,8 +216,7 @@ main()
|
||||
|
||||
/* Given this type id, how would we know this is a string
|
||||
* attribute? */
|
||||
if ((class = H5Tget_class(typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
if ((class = H5Tget_class(typeid)) < 0) ERR;
|
||||
if (class != H5T_STRING) ERR;
|
||||
|
||||
/* How many strings are in the array? */
|
||||
@ -303,8 +299,7 @@ main()
|
||||
|
||||
/* Given this type id, how would we know this is a string
|
||||
* attribute? */
|
||||
if ((class = H5Tget_class(typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
if ((class = H5Tget_class(typeid)) < 0) ERR;
|
||||
if (class != H5T_STRING) ERR;
|
||||
|
||||
/* How many strings are in the array? */
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
Here's a HDF5 sample programs:
|
||||
http://hdf.ncsa.uiuc.edu/training/other-ex5/sample-programs/strings.c
|
||||
|
||||
$Id: tst_h_strings1.c,v 1.3 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_strings1.h5"
|
||||
@ -159,8 +158,6 @@ main()
|
||||
hsize_t dims[NDIMS] = {NUM_STR}, max_dims[NDIMS] = {H5S_UNLIMITED};
|
||||
hsize_t chunk_dims[NDIMS] = {1};
|
||||
hsize_t xtend_size[NDIMS] = {2};
|
||||
hsize_t start[NDIMS] = {0}, count[NDIMS] = {NUM_STR};
|
||||
/* void *fillp;*/
|
||||
char *data[NUM_STR] = {
|
||||
"A man who carries a cat by the tail learns "
|
||||
"something he can learn in no other way."};
|
||||
|
@ -6,10 +6,9 @@
|
||||
|
||||
Here's a HDF5 sample programs:
|
||||
http://hdf.ncsa.uiuc.edu/training/other-ex5/sample-programs/strings.c
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_strings2.h5"
|
||||
|
@ -7,10 +7,9 @@
|
||||
tests don't work, than netCDF-4 won't work either.
|
||||
|
||||
This files tests dataset creation and writing.
|
||||
|
||||
$Id: tst_h_vars.c,v 1.18 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_vars.h5"
|
||||
@ -18,6 +17,7 @@
|
||||
#define VAR_BOOL_NAME "Southhamptons_Battle_Record"
|
||||
#define GRP2_NAME "Some_3D_Met_Data"
|
||||
#define DIM1_LEN 3
|
||||
#define MAX_DIMS 255
|
||||
|
||||
int
|
||||
main()
|
||||
@ -65,7 +65,7 @@ main()
|
||||
float float_data_out[LAT_LEN][LON_LEN];
|
||||
hsize_t dims[NDIMS], max_dims[NDIMS];
|
||||
hsize_t dims_in[NDIMS], max_dims_in[NDIMS];
|
||||
hsize_t start[NC_MAX_DIMS], count[NC_MAX_DIMS];
|
||||
hsize_t start[MAX_DIMS], count[MAX_DIMS];
|
||||
int lat, lon;
|
||||
|
||||
/* Set up some phoney data, 1 record's worth. In C, first
|
||||
|
@ -6,14 +6,14 @@
|
||||
exhaustive tests, but they use HDF5 the same way that netCDF-4
|
||||
does, so if these tests don't work, than netCDF-4 won't work
|
||||
either.
|
||||
|
||||
$Id: tst_h_vars2.c,v 1.26 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
#define FILE_NAME "tst_h_vars2.h5"
|
||||
#define STR_LEN 255
|
||||
|
||||
int
|
||||
main()
|
||||
@ -431,7 +431,7 @@ main()
|
||||
obs_t m = {-99, -99, -99, -99, -99};
|
||||
hid_t fileid, grpid, attid, typeid, datasetid, native_typeid, propid;
|
||||
H5D_fill_value_t fill_status;
|
||||
char file_in[NC_MAX_NAME * 2];
|
||||
char file_in[STR_LEN * 2];
|
||||
size_t type_size;
|
||||
|
||||
if (getenv("srcdir"))
|
||||
@ -486,7 +486,7 @@ main()
|
||||
hid_t datasetid[NUM_DATASETS];
|
||||
hid_t fileid, grpid, spaceid, plistid;
|
||||
hsize_t chunksize[NDIMS1], dimsize[NDIMS1], maxdimsize[NDIMS1];
|
||||
char var_name[NC_MAX_NAME + 1];
|
||||
char var_name[STR_LEN + 1];
|
||||
int v;
|
||||
|
||||
/* Create file, setting latest_format in access propertly list
|
||||
|
@ -6,10 +6,9 @@
|
||||
exhaustive tests, but they use HDF5 the same way that netCDF-4
|
||||
does, so if these tests don't work, than netCDF-4 won't work
|
||||
either.
|
||||
|
||||
$Id: tst_h_vars3.c,v 1.3 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
#include <H5DSpublic.h>
|
||||
|
||||
|
@ -3,10 +3,9 @@
|
||||
conditions of use.
|
||||
|
||||
This program excersizes HDF5 variable length array code.
|
||||
|
||||
$Id: tst_h_vl.c,v 1.11 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_vl.h5"
|
||||
@ -31,8 +30,7 @@ main()
|
||||
* pointer to a variable length array of int. */
|
||||
for (i=0; i<DIM1_LEN; i++)
|
||||
{
|
||||
if (!(phoney = malloc(sizeof(int) * (i+1))))
|
||||
return NC_ENOMEM;
|
||||
if (!(phoney = malloc(sizeof(int) * (i+1)))) ERR;
|
||||
for (j=0; j<i+1; j++)
|
||||
phoney[j] = -99;
|
||||
data[i].p = phoney;
|
||||
@ -108,8 +106,7 @@ main()
|
||||
/* /\* Create phoney data. *\/ */
|
||||
/* for (i=0; i<DIM1_LEN; i++) */
|
||||
/* { */
|
||||
/* if (!(phoney = malloc(sizeof(float) * (i+1)))) */
|
||||
/* return NC_ENOMEM; */
|
||||
/* if (!(phoney = malloc(sizeof(float) * (i+1)))) ERR; */
|
||||
/* for (j=0; j<i+1; j++) */
|
||||
/* phoney[j] = 23.5 - j; */
|
||||
/* data[i].temp_vl.p = phoney; */
|
||||
|
@ -3,10 +3,9 @@
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Test HDF5 compound types.
|
||||
|
||||
$Id: tst_h_wrt_cmp.c,v 1.7 2010/06/01 15:34:52 ed Exp $
|
||||
*/
|
||||
#include <nc_tests.h>
|
||||
|
||||
#include <err_macros.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#define FILE_NAME "tst_h_wrt_cmp.h5"
|
||||
|
@ -12,4 +12,4 @@ endif
|
||||
|
||||
noinst_HEADERS = nc_logging.h nc_tests.h fbits.h nc3dispatch.h nc.h \
|
||||
ncio.h nclist.h nc_url.h utf8proc.h ncdispatch.h ncdimscale.h \
|
||||
netcdf_f.h
|
||||
netcdf_f.h err_macros.h
|
||||
|
78
include/err_macros.h
Normal file
78
include/err_macros.h
Normal file
@ -0,0 +1,78 @@
|
||||
/* This is part of the netCDF package.
|
||||
Copyright 2005 University Corporation for Atmospheric Research/Unidata
|
||||
See COPYRIGHT file for conditions of use.
|
||||
|
||||
Common includes, defines, etc., for test code in the libsrc4 and
|
||||
nc_test4 directories.
|
||||
*/
|
||||
|
||||
#ifndef _ERR_MACROS_H
|
||||
#define _ERR_MACROS_H
|
||||
|
||||
#include <config.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Err is used to keep track of errors within each set of tests,
|
||||
* total_err is the number of errors in the entire test program, which
|
||||
* generally cosists of several sets of tests. */
|
||||
int total_err = 0, err = 0;
|
||||
|
||||
/* This is handy for print statements. */
|
||||
char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
|
||||
"netCDF-4 classic model"};
|
||||
|
||||
/* This macro prints an error message with line number and name of
|
||||
* test program. */
|
||||
#define ERR do { \
|
||||
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
|
||||
err++; \
|
||||
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return 2; \
|
||||
} while (0)
|
||||
|
||||
/* This macro prints an error message with line number and name of
|
||||
* test program, and then exits the program. */
|
||||
#define ERR_RET do { \
|
||||
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
|
||||
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return 2; \
|
||||
} while (0)
|
||||
|
||||
/* After a set of tests, report the number of errors, and increment
|
||||
* total_err. */
|
||||
#define SUMMARIZE_ERR do { \
|
||||
if (err) \
|
||||
{ \
|
||||
printf("%d failures\n", err); \
|
||||
total_err += err; \
|
||||
err = 0; \
|
||||
} \
|
||||
else \
|
||||
printf("ok.\n"); \
|
||||
} while (0)
|
||||
|
||||
/* If extra memory debugging is not in use (as it usually isn't),
|
||||
* define away the nc_exit function, which may be in some tests. */
|
||||
#ifndef EXTRA_MEM_DEBUG
|
||||
#define nc_exit()
|
||||
#endif
|
||||
|
||||
/* This macro prints out our total number of errors, if any, and exits
|
||||
* with a 0 if there are not, or a 2 if there were errors. Make will
|
||||
* stop if a non-zero value is returned from a test program. */
|
||||
#define FINAL_RESULTS do { \
|
||||
if (total_err) \
|
||||
{ \
|
||||
printf("%d errors detected! Sorry!\n", total_err); \
|
||||
return 2; \
|
||||
} \
|
||||
printf("*** Tests successful!\n"); \
|
||||
return 0; \
|
||||
} while (0)
|
||||
|
||||
#endif /* _ERR_MACROS_H */
|
@ -4,9 +4,8 @@
|
||||
|
||||
Common includes, defines, etc., for test code in the libsrc4 and
|
||||
nc_test4 directories.
|
||||
|
||||
$Id: nc_tests.h,v 1.3 2010/06/01 15:34:49 ed Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NC_TESTS_H
|
||||
#define _NC_TESTS_H
|
||||
|
||||
@ -19,65 +18,6 @@
|
||||
#include "netcdf_par.h"
|
||||
#endif
|
||||
#include "netcdf.h"
|
||||
|
||||
/* Err is used to keep track of errors within each set of tests,
|
||||
* total_err is the number of errors in the entire test program, which
|
||||
* generally cosists of several sets of tests. */
|
||||
int total_err = 0, err = 0;
|
||||
|
||||
/* This is handy for print statements. */
|
||||
char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
|
||||
"netCDF-4 classic model"};
|
||||
|
||||
/* This macro prints an error message with line number and name of
|
||||
* test program. */
|
||||
#define ERR do { \
|
||||
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
|
||||
err++; \
|
||||
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return 2; \
|
||||
} while (0)
|
||||
|
||||
/* This macro prints an error message with line number and name of
|
||||
* test program, and then exits the program. */
|
||||
#define ERR_RET do { \
|
||||
fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
|
||||
fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
|
||||
__FILE__, __LINE__); \
|
||||
return 2; \
|
||||
} while (0)
|
||||
|
||||
/* After a set of tests, report the number of errors, and increment
|
||||
* total_err. */
|
||||
#define SUMMARIZE_ERR do { \
|
||||
if (err) \
|
||||
{ \
|
||||
printf("%d failures\n", err); \
|
||||
total_err += err; \
|
||||
err = 0; \
|
||||
} \
|
||||
else \
|
||||
printf("ok.\n"); \
|
||||
} while (0)
|
||||
|
||||
/* If extra memory debugging is not in use (as it usually isn't),
|
||||
* define away the nc_exit function, which may be in some tests. */
|
||||
#ifndef EXTRA_MEM_DEBUG
|
||||
#define nc_exit()
|
||||
#endif
|
||||
|
||||
/* This macro prints out our total number of errors, if any, and exits
|
||||
* with a 0 if there are not, or a 2 if there were errors. Make will
|
||||
* stop if a non-zero value is returned from a test program. */
|
||||
#define FINAL_RESULTS do { \
|
||||
if (total_err) \
|
||||
{ \
|
||||
printf("%d errors detected! Sorry!\n", total_err); \
|
||||
return 2; \
|
||||
} \
|
||||
printf("*** Tests successful!\n"); \
|
||||
return 0; \
|
||||
} while (0)
|
||||
#include "err_macros.h"
|
||||
|
||||
#endif /* _NC_TESTS_H */
|
||||
|
@ -142,11 +142,11 @@ NC_put_vara(int ncid, int varid, const size_t *start,
|
||||
int ndims;
|
||||
stat = nc_inq_varndims(ncid, varid, &ndims);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
stat = getshape(ncid,varid,ndims,shape);
|
||||
stat = getshape(ncid, varid, ndims, shape);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
return ncp->dispatch->put_vara(ncid,varid,start,shape,value,memtype);
|
||||
return ncp->dispatch->put_vara(ncid, varid, start, shape, value, memtype);
|
||||
} else
|
||||
return ncp->dispatch->put_vara(ncid,varid,start,edges,value,memtype);
|
||||
return ncp->dispatch->put_vara(ncid, varid, start, edges, value, memtype);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1220,7 +1220,7 @@ nc_put_var1_long(int ncid, int varid, const size_t *coord, const long *value)
|
||||
int stat = NC_check_id(ncid, &ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
INITCOORD1;
|
||||
return NC_put_var1(ncid,varid,coord,(void*)value, longtype);
|
||||
return NC_put_var1(ncid, varid, coord, (void*)value, longtype);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1230,7 +1230,7 @@ nc_put_var1_float(int ncid, int varid, const size_t *coord, const float *value)
|
||||
int stat = NC_check_id(ncid, &ncp);
|
||||
if(stat != NC_NOERR) return stat;
|
||||
INITCOORD1;
|
||||
return NC_put_var1(ncid,varid,coord,(void*)value, NC_FLOAT);
|
||||
return NC_put_var1(ncid, varid, coord, (void*)value, NC_FLOAT);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -34,7 +34,7 @@ libnetcdf4_la_LIBADD += -lpnetcdf
|
||||
endif # USE_PNETCDF
|
||||
|
||||
# Always link to hdf5_hl, hdf5, and z.
|
||||
libnetcdf4_la_LIBADD += -lhdf5_hl -lhdf5 -lz -lm
|
||||
libnetcdf4_la_LIBADD += -lhdf5_hl -lhdf5 -lz
|
||||
|
||||
# This turns on declspec magic in netcdf.h for windows DLLs.
|
||||
if BUILD_DLL
|
||||
|
@ -721,7 +721,7 @@ nc4_put_vara(NC_FILE_INFO_T *nc, int ncid, int varid, const size_t *startp,
|
||||
{
|
||||
xtend_size[d2] = dim->len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we need to extend it, we also need a new file_spaceid
|
||||
to reflect the new size of the space. */
|
||||
@ -734,9 +734,6 @@ nc4_put_vara(NC_FILE_INFO_T *nc, int ncid, int varid, const size_t *startp,
|
||||
BAIL2(NC_EHDFERR);
|
||||
if ((file_spaceid = H5Dget_space(var->hdf_datasetid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
#ifdef EXTRA_TESTS
|
||||
num_spaces++;
|
||||
#endif
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
@ -46,11 +46,11 @@ endif # LARGE_FILE_TESTS
|
||||
if BUILD_BENCHMARKS
|
||||
check_PROGRAMS += tst_create_files bm_file tst_chunks3 tst_ar4 \
|
||||
tst_ar4_3d tst_ar4_4d bm_many_objs tst_h_many_atts bm_many_atts \
|
||||
tst_files2 tst_files3 tst_ar5 tst_h_files3
|
||||
tst_files2 tst_files3 tst_ar5 tst_h_files3 tst_mem
|
||||
|
||||
TESTS += tst_ar4_3d tst_create_files run_bm_test1.sh run_bm_elena.sh \
|
||||
run_bm_test2.sh run_tst_chunks.sh run_bm_ar4.sh tst_files2 tst_files3 \
|
||||
tst_ar5 tst_h_files3
|
||||
tst_ar5 tst_h_files3 tst_mem
|
||||
|
||||
# This will run a parallel I/O benchmark for parallel builds.
|
||||
if TEST_PARALLEL
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <nc_tests.h>
|
||||
|
||||
|
||||
#define FILE_NAME "tst_rename.nc"
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user