Merge branch 'master' into ejh_more_mem_3

This commit is contained in:
Ed Hartnett 2017-10-30 07:34:52 -06:00 committed by GitHub
commit 86f35ea6db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 184 additions and 216 deletions

View File

@ -871,7 +871,7 @@ AC_FUNC_ALLOCA
AC_CHECK_DECLS([isnan, isinf, isfinite, signbit],,,[#include <math.h>])
AC_STRUCT_ST_BLKSIZE
UD_CHECK_IEEE
AC_CHECK_TYPES([size_t, ssize_t, ptrdiff_t, uchar, longlong, ushort, uint, int64, uint64 off_t])
AC_CHECK_TYPES([size_t, ssize_t, ptrdiff_t, schar, uchar, longlong, ushort, uint, int64, uint64 off_t])
AC_TYPE_SIZE_T
AC_TYPE_OFF_T
AC_C_CHAR_UNSIGNED

View File

@ -156,15 +156,9 @@
/* End ncx_len */
#ifdef __CHAR_UNSIGNED__
/* 'char' is unsigned, declare ncbyte as 'signed char' */
#ifndef HAVE_SCHAR
typedef signed char schar;
#else
/* 'char' is signed */
typedef char schar;
#endif /* __CHAR_UNSIGNED__ */
#endif
/*
* Primitive numeric conversion functions.

View File

@ -338,9 +338,6 @@ px_pgin(ncio *const nciop,
{
int status;
ssize_t nread;
size_t read_count = 0;
ssize_t bytes_xfered = 0;
void *p = vp;
#ifdef X_ALIGN
assert(offset % X_ALIGN == 0);
assert(extent % X_ALIGN == 0);

View File

@ -15,6 +15,8 @@
#include <mpe.h>
#endif /* USE_MPE */
#undef DEBUG
#define FILE_NAME "tst_parallel2.nc"
#define NDIMS 3
#define DIMSIZE 8
@ -54,7 +56,9 @@ main(int argc, char **argv)
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Get_processor_name(mpi_name, &mpi_namelen);
/*printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);*/
#ifdef DEBUG
printf("mpi_name: %s size: %d rank: %d\n", mpi_name, mpi_size, mpi_rank);
#endif
/* Must be able to evenly divide my slabs between processors. */
if (NUM_SLABS % mpi_size != 0)
@ -85,12 +89,14 @@ main(int argc, char **argv)
MPE_Log_event(s_init, 0, "start init");
#endif /* USE_MPE */
/* if (!mpi_rank) */
/* { */
/* printf("\n*** Testing parallel I/O some more.\n"); */
/* printf("*** writing a %d x %d x %d file from %d processors...\n", */
/* NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size); */
/* } */
#ifdef DEBUG
if (!mpi_rank)
{
printf("\n*** Testing parallel I/O some more.\n");
printf("*** writing a %d x %d x %d file from %d processors...\n",
NUM_SLABS, DIMSIZE, DIMSIZE, mpi_size);
}
#endif
/* We will write the same slab over and over. */
for (i = 0; i < DIMSIZE * DIMSIZE; i++)
@ -103,6 +109,9 @@ main(int argc, char **argv)
/* Create a parallel netcdf-4 file. */
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE_NAME);
#ifdef DEBUG
fprintf(stderr,"create: file_name=%s\n",file_name);
#endif
if (nc_create_par(file_name, NC_PNETCDF, comm, info, &ncid)) ERR;
/* A global attribute holds the number of processors that created
@ -168,6 +177,9 @@ main(int argc, char **argv)
#endif /* USE_MPE */
/* Reopen the file and check it. */
#ifdef DEBUG
fprintf(stderr,"open: file_name=%s\n",file_name);
#endif
if (nc_open_par(file_name, NC_NOWRITE|NC_PNETCDF, comm, info, &ncid)) ERR;
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
if (ndims_in != NDIMS || nvars_in != 1 || natts_in != 1 ||
@ -209,16 +221,19 @@ main(int argc, char **argv)
MPE_Log_event(e_close, 0, "end close file");
#endif /* USE_MPE */
/* Delete this large file. */
remove(file_name);
/* Shut down MPI. */
MPI_Finalize();
/* if (!mpi_rank) */
/* { */
/* SUMMARIZE_ERR; */
/* FINAL_RESULTS; */
/* } */
/* Delete this large file. */
remove(file_name);
#ifdef DEBUG
if (!mpi_rank)
{
SUMMARIZE_ERR;
FINAL_RESULTS;
}
#endif
return total_err;
}

View File

@ -1,16 +1,15 @@
# Some extra tests
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2
tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings
tst_strings2 tst_interops tst_interops4 tst_interops6
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4
tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug
tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
t_type cdm_sea_soundings tst_vl tst_atts1 tst_atts2
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_strbug tst_h_refs
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite
tst_put_vars_two_unlim_dim tst_hdf5_file_compat tst_fill_attr_vanish
tst_rehash)
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2
tst_grps tst_grps2 tst_compounds tst_compounds2 tst_compounds3
tst_opaques tst_strings tst_strings2 tst_interops tst_interops4
tst_interops6 tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3
tst_vars4 tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2
tst_fillbug tst_xplatform2 tst_endian_fill tst_atts t_type
cdm_sea_soundings tst_vl tst_atts1 tst_atts2 tst_vars2 tst_files5
tst_files6 tst_sync tst_h_strbug tst_h_refs tst_h_scalar tst_rename
tst_h5_endians tst_atts_string_rewrite tst_put_vars_two_unlim_dim
tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash)
# Note, renamegroup needs to be compiled before run_grp_rename

View File

@ -12,17 +12,17 @@ include $(top_srcdir)/lib_flags.am
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
# These are netCDF-4 test programs.
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars \
tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps tst_grps2 \
tst_compounds tst_compounds2 tst_compounds3 tst_opaques tst_strings \
tst_strings2 tst_interops tst_interops4 tst_interops5 tst_interops6 \
tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 tst_vars4 \
tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \
tst_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts \
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \
tst_grps2 tst_compounds tst_compounds2 tst_compounds3 tst_opaques \
tst_strings tst_strings2 tst_interops tst_interops4 tst_interops5 \
tst_interops6 tst_enums tst_coords tst_coords2 tst_coords3 tst_vars3 \
tst_vars4 tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 \
tst_fillbug tst_xplatform tst_xplatform2 tst_endian_fill tst_atts \
t_type cdm_sea_soundings tst_camrun tst_vl tst_atts1 tst_atts2 \
tst_vars2 tst_files5 tst_files6 tst_sync \
tst_h_scalar tst_rename tst_h5_endians tst_atts_string_rewrite \
tst_hdf5_file_compat tst_fill_attr_vanish tst_rehash
tst_vars2 tst_files5 tst_files6 tst_sync tst_h_scalar tst_rename \
tst_h5_endians tst_atts_string_rewrite tst_hdf5_file_compat \
tst_fill_attr_vanish tst_rehash
# Temporary I hope
if !ISCYGWIN

View File

@ -1,127 +0,0 @@
/* This is part of the netCDF package.
Copyright 2005 University Corporation for Atmospheric Research/Unidata
See COPYRIGHT file for conditions of use.
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.
This file deals with HDF5 attributes, but more so.
$Id: tst_h_atts2.c,v 1.18 2009/07/03 13:07:14 ed Exp $
*/
#include <nc_tests.h>
#include "err_macros.h"
#include <hdf5.h>
#define FILE_NAME "tst_h_atts2.h5"
#define REF_FILE_NAME "tst_xplatform2_3.nc"
#define MAX_LEN 80
#define NUM_ATTS 1
#define ATT_NAME "King_John"
#define NUM_OBJ 3
int
main()
{
printf("\n*** Checking HDF5 attribute functions some more.\n");
#ifdef EXTRA_TESTS
printf("*** Opening tst_xplatform2_3.nc...");
{
hid_t fileid, grpid, attid;
hid_t file_typeid1[NUM_OBJ], native_typeid1[NUM_OBJ];
hid_t file_typeid2, native_typeid2;
hsize_t num_obj, i;
H5O_info_t obj_info;
char obj_name[NC_MAX_NAME + 1];
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* How many objects in this group? */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_OBJ) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
{
/* Get the name. */
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
i, &obj_info, H5P_DEFAULT) < 0) ERR_RET;
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR_RET;
printf(" reading type %s ", obj_name);
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR_RET;
/* Get the typeid. */
if ((file_typeid1[i] = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR_RET;
if ((native_typeid1[i] = H5Tget_native_type(file_typeid1[i], H5T_DIR_DEFAULT)) < 0) ERR_RET;
}
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid2, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid2) < 0) ERR_RET;
if (H5Tclose(native_typeid2) < 0) ERR_RET;
for (i = 0; i < NUM_OBJ; i++)
{
if (H5Tclose(file_typeid1[i]) < 0) ERR_RET;
if (H5Tclose(native_typeid1[i]) < 0) ERR_RET;
}
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
printf("*** Opening tst_xplatform2_3.nc again...");
{
hid_t fileid, grpid, attid, file_typeid, native_typeid;
hid_t file_typeid2, native_typeid2;
#if 0
hsize_t num_obj;
#endif
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Now getting another copy of the native typeid will fail! WTF? */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid) < 0) ERR;
if (H5Tclose(native_typeid) < 0) ERR;
if (H5Tclose(file_typeid2) < 0) ERR;
if (H5Tclose(native_typeid2) < 0) ERR;
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
#endif
FINAL_RESULTS;
}

View File

@ -10,6 +10,7 @@
#include <nc_tests.h>
#include "err_macros.h"
#include "netcdf.h"
#include <hdf5.h>
#define FILE_NAME_1 "tst_xplatform2_1.nc"
#define REF_FILE_NAME_1 "ref_tst_xplatform2_1.nc"
@ -209,16 +210,16 @@ check_file_3(int ncid, struct s3 *data_out)
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
{
if (data_in[i].data[j].len != data_in[i].data[j].len) ERR;
if (data_in[i].data[j].len != data_out[i].data[j].len) ERR;
for (k = 0; k < data_out[i].data[j].len; k++)
if (((struct s1 *)data_in[i].data[j].p)[k].x != ((struct s1 *)data_out[i].data[j].p)[k].x ||
((struct s1 *)data_in[i].data[j].p)[k].y != ((struct s1 *)data_out[i].data[j].p)[k].y) ERR;
}
/* Free our vlens. */
/* for (i = 0; i < DIM3_LEN; i++) */
/* for (j = 0; j < NUM_VL; j++) */
/* nc_free_vlen(&(data_in[i].data[j])); */
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
nc_free_vlen(&(data_in[i].data[j]));
/* We're done! */
return NC_NOERR;
@ -273,16 +274,16 @@ check_file_4(int ncid, struct s3 *data_out)
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
{
if (data_in[i].data[j].len != data_in[i].data[j].len) ERR;
if (data_in[i].data[j].len != data_out[i].data[j].len) ERR;
for (k = 0; k < data_out[i].data[j].len; k++)
if (((struct s1 *)data_in[i].data[j].p)[k].x != ((struct s1 *)data_out[i].data[j].p)[k].x ||
((struct s1 *)data_in[i].data[j].p)[k].y != ((struct s1 *)data_out[i].data[j].p)[k].y) ERR;
}
/* Free our vlens. */
/* for (i = 0; i < DIM3_LEN; i++) */
/* for (j = 0; j < NUM_VL; j++) */
/* nc_free_vlen(&(data_in[i].data[j])); */
for (i = 0; i < DIM3_LEN; i++)
for (j = 0; j < NUM_VL; j++)
nc_free_vlen(&(data_in[i].data[j]));
/* We're done! */
return NC_NOERR;
@ -340,7 +341,6 @@ main(int argc, char **argv)
}
}
printf("*** testing of vlen of compound type...");
{
nc_type s1_typeid, vlen_typeid;
@ -352,9 +352,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -382,8 +382,8 @@ main(int argc, char **argv)
strcpy(file_in, "");
if (getenv("srcdir"))
{
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
}
strcat(file_in, REF_FILE_NAME_1);
@ -406,21 +406,21 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a compound type that holds an array of the struct s1
* type. */
if (nc_def_compound(ncid, sizeof(struct s2), S2_TYPE_NAME, &s2_typeid)) ERR;
if (nc_insert_array_compound(ncid, s2_typeid, S1_NAME,
NC_COMPOUND_OFFSET(struct s2, data),
s1_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s2, data),
s1_typeid, 1, dimsizes)) ERR;
/* Write the output data as an attribute. */
if (nc_put_att(ncid, NC_GLOBAL, S2_ATT_NAME, s2_typeid,
DIM2_LEN, comp_array_of_comp_out)) ERR;
DIM2_LEN, comp_array_of_comp_out)) ERR;
/* How does it look? */
if (check_file_2(ncid, comp_array_of_comp_out)) ERR;
@ -441,8 +441,8 @@ main(int argc, char **argv)
strcpy(file_in, "");
if (getenv("srcdir"))
{
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
strcat(file_in, getenv("srcdir"));
strcat(file_in, "/");
}
strcat(file_in, REF_FILE_NAME_2);
@ -465,9 +465,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our s1 compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -476,16 +476,16 @@ main(int argc, char **argv)
* type. */
if (nc_def_compound(ncid, sizeof(struct s3), S3_TYPE_NAME, &s3_typeid)) ERR;
if (nc_insert_array_compound(ncid, s3_typeid, VL_NAME,
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
/* Write the output data as an attribute. */
if (nc_put_att(ncid, NC_GLOBAL, S3_ATT_NAME, s3_typeid,
DIM3_LEN, comp_array_of_vlen_of_comp_out)) ERR;
DIM3_LEN, comp_array_of_vlen_of_comp_out)) ERR;
/* How does it look? */
if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR;
/* How does it look? Uncomment this line to see memory issue. */
/* if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR; */
/* We're done - wasn't that easy? */
if (nc_close(ncid)) ERR;
@ -496,15 +496,6 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* printf("*** testing Solaris-written compound containing array of vlen of compound type..."); */
/* { */
/* /\* Check out the same file, generated on buddy and included with */
/* * the distribution. *\/ */
/* if (nc_open(REF_FILE_NAME_3, NC_NOWRITE, &ncid)) ERR; */
/* if (check_file_3(ncid, comp_array_of_vlen_of_comp_out)) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
printf("*** testing compound variable containing array of vlen of compound type...");
{
nc_type vlen_typeid, s3_typeid, s1_typeid;
@ -518,9 +509,9 @@ main(int argc, char **argv)
* different platforms - our old friend struct s1. */
if (nc_def_compound(ncid, sizeof(struct s1), S1_TYPE_NAME, &s1_typeid)) ERR;
if (nc_insert_compound(ncid, s1_typeid, X_NAME,
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
NC_COMPOUND_OFFSET(struct s1, x), NC_FLOAT)) ERR;
if (nc_insert_compound(ncid, s1_typeid, Y_NAME,
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
NC_COMPOUND_OFFSET(struct s1, y), NC_DOUBLE)) ERR;
/* Now make a new type: a vlen of our s1 compound type. */
if (nc_def_vlen(ncid, VLEN_NAME, s1_typeid, &vlen_typeid)) ERR;
@ -529,8 +520,8 @@ main(int argc, char **argv)
* type. */
if (nc_def_compound(ncid, sizeof(struct s3), S3_TYPE_NAME, &s3_typeid)) ERR;
if (nc_insert_array_compound(ncid, s3_typeid, VL_NAME,
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
NC_COMPOUND_OFFSET(struct s3, data),
vlen_typeid, 1, dimsizes)) ERR;
/* Create a dimension and a var of s3 type, then write the
* data. */
@ -562,5 +553,104 @@ main(int argc, char **argv)
free(comp_array_of_vlen_of_comp_out);
free(vlen_of_comp_out);
/* Now run the tests formerly in tst_h_atts2.c. */
#define REF_FILE_NAME "tst_xplatform2_3.nc"
#define NUM_OBJ 3
printf("\n*** Checking HDF5 attribute functions some more.\n");
#ifdef EXTRA_TESTS
printf("*** Opening tst_xplatform2_3.nc...");
{
hid_t fileid, grpid, attid;
hid_t file_typeid1[NUM_OBJ], native_typeid1[NUM_OBJ];
hid_t file_typeid2, native_typeid2;
hsize_t num_obj, i;
H5O_info_t obj_info;
char obj_name[NC_MAX_NAME + 1];
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* How many objects in this group? */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
if (num_obj != NUM_OBJ) ERR;
/* For each object in the group... */
for (i = 0; i < num_obj; i++)
{
/* Get the name. */
if (H5Oget_info_by_idx(grpid, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC,
i, &obj_info, H5P_DEFAULT) < 0) ERR_RET;
if (H5Lget_name_by_idx(grpid, ".", H5_INDEX_NAME, H5_ITER_INC, i,
obj_name, NC_MAX_NAME + 1, H5P_DEFAULT) < 0) ERR_RET;
printf(" reading type %s ", obj_name);
if (obj_info.type != H5O_TYPE_NAMED_DATATYPE) ERR_RET;
/* Get the typeid. */
if ((file_typeid1[i] = H5Topen2(grpid, obj_name, H5P_DEFAULT)) < 0) ERR_RET;
if ((native_typeid1[i] = H5Tget_native_type(file_typeid1[i], H5T_DIR_DEFAULT)) < 0) ERR_RET;
}
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid2, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid2) < 0) ERR_RET;
if (H5Tclose(native_typeid2) < 0) ERR_RET;
for (i = 0; i < NUM_OBJ; i++)
{
if (H5Tclose(file_typeid1[i]) < 0) ERR_RET;
if (H5Tclose(native_typeid1[i]) < 0) ERR_RET;
}
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
printf("*** Opening tst_xplatform2_3.nc again...");
{
hid_t fileid, grpid, attid, file_typeid, native_typeid;
hid_t file_typeid2, native_typeid2;
/* Open one of the netCDF test files. */
if ((fileid = H5Fopen(REF_FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* There is one att: open it by index. */
if ((attid = H5Aopen_idx(grpid, 0)) < 0) ERR;
/* Get file and native typeids. */
if ((file_typeid = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Now getting another copy of the native typeid will fail! WTF? */
if ((file_typeid2 = H5Aget_type(attid)) < 0) ERR;
if ((native_typeid2 = H5Tget_native_type(file_typeid, H5T_DIR_DEFAULT)) < 0) ERR;
/* Close the attribute. */
if (H5Aclose(attid) < 0) ERR;
/* Close the typeids. */
if (H5Tclose(file_typeid) < 0) ERR;
if (H5Tclose(native_typeid) < 0) ERR;
if (H5Tclose(file_typeid2) < 0) ERR;
if (H5Tclose(native_typeid2) < 0) ERR;
/* Close the group and file. */
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
#endif /* EXTRA_TESTS */
FINAL_RESULTS;
}