conflicts

This commit is contained in:
dmh 2015-05-16 15:53:48 -06:00
commit c2f880f0f3
18 changed files with 27571 additions and 27394 deletions

View File

@ -339,6 +339,7 @@ ENDIF()
# Option Logging, only valid for netcdf4.
OPTION(ENABLE_LOGGING "Enable Logging." OFF)
IF(ENABLE_LOGGING)
ADD_DEFINITIONS(-DLOGGING)
SET(LOGGING ON)
ENDIF()
@ -1374,6 +1375,7 @@ IF(ENABLE_TESTS)
ENDIF()
ADD_SUBDIRECTORY(nc_test)
IF(USE_NETCDF4)
INCLUDE_DIRECTORIES(h5_test)
ADD_SUBDIRECTORY(nc_test4)
ADD_SUBDIRECTORY(h5_test)
ENDIF()

View File

@ -5,7 +5,9 @@ Release Notes {#RELEASE_NOTES}
This file contains a high-level description of this package's evolution. Releases are in reverse chronological order (most recent first). Note that, as of netcdf 4.2, the `netcdf-c++` and `netcdf-fortran` libraries have been separated into their own libraries.
## 4.3.X Released TBD
## 4.3.x Released TBD
* Addressed an issure in netcdf4 related to specifying an endianness explicitly. When specifying an endianness for `NC_FLOAT`, the value would appear to not be written to file, if checked with `ncdump -s`. The issue was more subtle; the value would be written but was not being read from file properly for non-`NC_INT`. See [GitHub Issue](https://github.com/Unidata/netcdf-c/issues/112) or [NCF-331](https://bugtracking.unidata.ucar.edu/browse/NCF-331) for more information.
* Addressed an issue in netcdf4 on Windows w/DAP related to how byte values were copied with sscanf. Issue originally reported by Ellen Johnson at Mathworks, see [NCF-330](https://bugtracking.unidata.ucar.edu/browse/NCF-330) for more information.

View File

@ -18,5 +18,3 @@ FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SO
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} ref_tst_h_compounds.h5 ref_tst_h_compounds2.h5 ref_tst_compounds.nc CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -1,7 +1,7 @@
# This is part of the netCDF package.
# Copyright 2011 University Corporation for Atmospheric Research/Unidata
# See COPYRIGHT file for conditions of use.
#
#
# This entire directory will be skipped, unless the configure script
# is run with --enable-netcdf-4. This directory contains tests that
# only use HDF5; these tests don't use netCDF at all.
@ -18,7 +18,7 @@ tst_h_atts3 tst_h_atts4 tst_h_vars tst_h_vars2 tst_h_vars3 tst_h_grps \
tst_h_compounds tst_h_compounds2 tst_h_wrt_cmp tst_h_rd_cmp tst_h_vl \
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 tst_h_dimscales4 #tst_h_filters
tst_h_enums tst_h_dimscales4 #tst_h_filters
# If benchmarks were turned on, build and run a bunch more tests.
if BUILD_BENCHMARKS
@ -40,7 +40,7 @@ endif
# This will run a bunch of the test programs with valgrind, the memory
# checking tool. (Valgrind must be present for this to work.)
if USE_VALGRIND_TESTS
TESTS += run_valgrind_tests.sh
TESTS += run_valgrind_tests.sh
endif # USE_VALGRIND_TESTS
# We must include these files in the distribution.
@ -50,8 +50,3 @@ run_valgrind_tests.sh ref_tst_compounds.nc h5_err_macros.h CMakeLists.txt
# Clean up test results.
CLEANFILES = tst_h_*.h5

View File

@ -0,0 +1,83 @@
/* 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 files tests dataset creation and writing.
*/
#include "h5_err_macros.h"
#include <hdf5.h>
#define FILE_NAME "tst_h_endian_float.h5"
#define GRP_NAME "Henry_V"
#define VAR_BOOL_NAME "Southhamptons_Battle_Record"
#define GRP2_NAME "Some_3D_Met_Data"
#define DIM1_LEN 3
#define MAX_DIMS 255
int
main()
{
hid_t fileid, grpid, spaceid, datasetid;
int bool_out[DIM1_LEN] = {0, 1, 0};
hsize_t dims[1];
printf("*** Checking HDF5 endianness control...");
#define NATIVE_VAR_NAME "native_var"
#define LE_VAR_NAME "le_var"
#define BE_VAR_NAME "be_var"
#define LAT_LEN 2
#define LON_LEN 3
#define NDIMS 3
#define LAT_NAME "Lat"
#define LON_NAME "Lon"
#define TIME_NAME "Time"
#define PRES_NAME "Pressure"
#define TEMP_NAME "Temperature"
{
int data[DIM1_LEN], data_in[DIM1_LEN];
hid_t typeid, native_typeid;
hid_t native_did, le_did, be_did;
H5T_order_t order;
htri_t equal;
int i;
float float_data_out[LAT_LEN][LON_LEN];
int lat, lon;
for (lat = 0; lat < LAT_LEN; lat++)
for (lon = 0; lon < LON_LEN; lon++)
float_data_out[lat][lon] = -666.666;
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
/* Create a dataset of native endian. */
dims[0] = DIM1_LEN;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((native_did = H5Dcreate(grpid, NATIVE_VAR_NAME, H5T_STD_I32BE,
spaceid, H5P_DEFAULT)) < 0) ERR;
if ((le_did = H5Dcreate(grpid, LE_VAR_NAME, H5T_IEEE_F32LE,
spaceid, H5P_DEFAULT)) < 0) ERR;
if ((be_did = H5Dcreate(grpid, BE_VAR_NAME, H5T_IEEE_F32BE,
spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5Dclose(native_did) < 0 ||
H5Dclose(le_did) < 0 ||
H5Dclose(be_did) < 0 ||
H5Sclose(spaceid) < 0 ||
H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0)
ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}

View File

@ -30,16 +30,16 @@ main()
printf("*** Checking HDF5 boolen variables...");
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
/* Write an array of bools. */
dims[0] = DIM1_LEN;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
bool_out) < 0) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Sclose(spaceid) < 0 ||
@ -75,7 +75,7 @@ main()
float_data_out[lat][lon] = -666.666;
/* Create file and group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP2_NAME, 0)) < 0) ERR;
@ -96,14 +96,14 @@ main()
if (H5Pset_chunk(cparmsid, NDIMS, dims) < 0) ERR;
/* Create two variables which use this space. */
if ((pres_dsid = H5Dcreate(grpid, PRES_NAME, H5T_NATIVE_FLOAT,
if ((pres_dsid = H5Dcreate(grpid, PRES_NAME, H5T_NATIVE_FLOAT,
spaceid, cparmsid)) < 0) ERR;
if ((temp_dsid = H5Dcreate(grpid, TEMP_NAME, H5T_NATIVE_FLOAT,
if ((temp_dsid = H5Dcreate(grpid, TEMP_NAME, H5T_NATIVE_FLOAT,
spaceid, cparmsid)) < 0) ERR;
/* Get the spaceid and check various things. */
if ((spaceid_in = H5Dget_space(pres_dsid)) < 0) ERR;
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
max_dims_in) < 0) ERR;
if (dims_in[0] != 0 || dims_in[1] != LAT_LEN || dims_in[2] != LON_LEN) ERR;
if (max_dims_in[0] != H5S_UNLIMITED || max_dims_in[1] != LAT_LEN || max_dims_in[2] != LON_LEN) ERR;
@ -122,14 +122,14 @@ main()
if ((write_spaceid = H5Screate_simple(NDIMS, dims, NULL)) < 0) ERR;
/* Write one record of data to each dataset. */
if (H5Dwrite(pres_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
if (H5Dwrite(pres_dsid, H5T_IEEE_F32BE, mem_spaceid, write_spaceid,
H5P_DEFAULT, float_data_out) < 0) ERR;
if (H5Dwrite(temp_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
if (H5Dwrite(temp_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
H5P_DEFAULT, float_data_out) < 0) ERR;
/* Get the spaceid and check various things. */
if ((spaceid_in = H5Dget_space(temp_dsid)) < 0) ERR;
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
max_dims_in) < 0) ERR;
if (dims_in[0] != 1 || dims_in[1] != LAT_LEN || dims_in[2] != LON_LEN) ERR;
if (max_dims_in[0] != H5S_UNLIMITED || max_dims_in[1] != LAT_LEN || max_dims_in[2] != LON_LEN) ERR;
@ -149,18 +149,18 @@ main()
start[0] = 1;
start[1] = 0;
start[2] = 0;
if (H5Sselect_hyperslab(write_spaceid, H5S_SELECT_SET,
if (H5Sselect_hyperslab(write_spaceid, H5S_SELECT_SET,
start, NULL, count, NULL) < 0) ERR;
/* Write second record of data to each dataset. */
if (H5Dwrite(pres_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
if (H5Dwrite(pres_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
H5P_DEFAULT, float_data_out) < 0) ERR;
if (H5Dwrite(temp_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
if (H5Dwrite(temp_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
H5P_DEFAULT, float_data_out) < 0) ERR;
/* Get the spaceid and check various things. */
if ((spaceid_in = H5Dget_space(pres_dsid)) < 0) ERR;
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
if (H5Sget_simple_extent_dims(spaceid_in, dims_in,
max_dims_in) < 0) ERR;
if (dims_in[0] != 2 || dims_in[1] != LAT_LEN || dims_in[2] != LON_LEN) ERR;
if (max_dims_in[0] != H5S_UNLIMITED || max_dims_in[1] != LAT_LEN || max_dims_in[2] != LON_LEN) ERR;
@ -171,13 +171,13 @@ main()
H5Sclose(spaceid) < 0 ||
H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
printf("*** Checking HDF5 deflate filter setting and getting...");
#define DEFLATE_LEVEL 9
#define MAX_NAME 100
#define MAX_NAME 100
#define NUM_CD_ELEM 10
/* HDF5 defines this... */
#define DEFLATE_NAME "deflate"
@ -189,13 +189,13 @@ main()
size_t cd_nelems = NUM_CD_ELEM;
size_t namelen = MAX_NAME;
char name[MAX_NAME + 1];
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
/* Write an array of bools, with compression. */
dims[0] = DIM1_LEN;
if ((propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR;
@ -203,9 +203,9 @@ main()
if (H5Pset_chunk(propid, 1, dims)) ERR;
if (H5Pset_deflate(propid, DEFLATE_LEVEL)) ERR;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
spaceid, propid)) < 0) ERR;
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
bool_out) < 0) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
@ -224,11 +224,11 @@ main()
* found in H5Zpublic.h. */
if ((num_filters = H5Pget_nfilters(propid)) < 0) ERR;
if (num_filters != 1) ERR;
if ((filter = H5Pget_filter2(propid, 0, &flags, &cd_nelems, cd_values,
if ((filter = H5Pget_filter2(propid, 0, &flags, &cd_nelems, cd_values,
namelen, name, &filter_config)) < 0) ERR;
if (filter != H5Z_FILTER_DEFLATE || cd_nelems != 1 ||
cd_values[0] != DEFLATE_LEVEL || strcmp(name, DEFLATE_NAME)) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
H5Gclose(grpid) < 0 ||
@ -250,10 +250,10 @@ main()
int f;
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
/* Write an array of bools, with compression, fletcher32
* checksum, shuffle filters. Like a hoogie with "the works." */
dims[0] = DIM1_LEN;
@ -264,9 +264,9 @@ main()
if (H5Pset_deflate(propid, DEFLATE_LEVEL)) ERR;
if (H5Pset_fletcher32(propid)) ERR;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
if ((datasetid = H5Dcreate(grpid, VAR_BOOL_NAME, H5T_NATIVE_HBOOL,
spaceid, propid)) < 0) ERR;
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(datasetid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT,
bool_out) < 0) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
@ -287,7 +287,7 @@ main()
if (num_filters != 3) ERR;
for (f = 0; f < num_filters; f++)
{
if ((filter = H5Pget_filter2(propid, f, &flags, &cd_nelems, cd_values,
if ((filter = H5Pget_filter2(propid, f, &flags, &cd_nelems, cd_values,
namelen, name, &filter_config)) < 0) ERR;
switch (filter)
{
@ -299,7 +299,7 @@ main()
break;
case H5Z_FILTER_DEFLATE:
found_deflate++;
if (cd_nelems != 1 || cd_values[0] != DEFLATE_LEVEL ||
if (cd_nelems != 1 || cd_values[0] != DEFLATE_LEVEL ||
strcmp(name, DEFLATE_NAME)) ERR;
break;
default:
@ -307,7 +307,7 @@ main()
}
}
if (!found_fletcher32 || !found_deflate || !found_shuffle) ERR;
if (H5Dclose(datasetid) < 0 ||
H5Pclose(propid) < 0 ||
H5Gclose(grpid) < 0 ||
@ -333,24 +333,24 @@ main()
data[i] = i;
/* Open file and create group. */
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
/* Create a dataset of native endian. */
dims[0] = DIM1_LEN;
if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
if ((native_did = H5Dcreate(grpid, NATIVE_VAR_NAME, H5T_NATIVE_INT,
if ((native_did = H5Dcreate(grpid, NATIVE_VAR_NAME, H5T_NATIVE_INT,
spaceid, H5P_DEFAULT)) < 0) ERR;
if ((le_did = H5Dcreate(grpid, LE_VAR_NAME, H5T_STD_I32LE,
if ((le_did = H5Dcreate(grpid, LE_VAR_NAME, H5T_STD_I32LE,
spaceid, H5P_DEFAULT)) < 0) ERR;
if ((be_did = H5Dcreate(grpid, BE_VAR_NAME, H5T_STD_I32BE,
if ((be_did = H5Dcreate(grpid, BE_VAR_NAME, H5T_STD_I32BE,
spaceid, H5P_DEFAULT)) < 0) ERR;
if (H5Dwrite(native_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(native_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;
if (H5Dwrite(le_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(le_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;
if (H5Dwrite(be_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dwrite(be_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data) < 0) ERR;
if (H5Dclose(native_did) < 0 ||
H5Dclose(le_did) < 0 ||
@ -371,7 +371,7 @@ main()
if ((equal = H5Tequal(typeid, native_typeid)) < 0) ERR;
if (!equal) ERR;
if (H5Dread(native_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dread(native_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data_in) < 0) ERR;
for (i = 0; i < DIM1_LEN; i++)
if (data[i] != data_in[i]) ERR;
@ -381,7 +381,7 @@ main()
if ((order = H5Tget_order(typeid)) < 0) ERR;
if (order != H5T_ORDER_LE) ERR;
if (H5Dread(le_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dread(le_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data_in) < 0) ERR;
for (i = 0; i < DIM1_LEN; i++)
if (data[i] != data_in[i]) ERR;
@ -391,7 +391,7 @@ main()
if ((order = H5Tget_order(typeid)) < 0) ERR;
if (order != H5T_ORDER_BE) ERR;
if (H5Dread(be_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
if (H5Dread(be_did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
data_in) < 0) ERR;
for (i = 0; i < DIM1_LEN; i++)
if (data[i] != data_in[i]) ERR;

16646
libsrc/ncx.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -895,31 +895,27 @@ get_type_info2(NC_HDF5_FILE_INFO_T *h5, hid_t datasetid,
break;
}
/* Find out about endianness. */
if (class == H5T_INTEGER)
{
if ((order = H5Tget_order(hdf_typeid)) < 0)
return NC_EHDFERR;
/* Find out about endianness.
* As of HDF 1.8.6, this works with all data types
* Not just H5T_INTEGER.
*
* See https://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-GetOrder
*/
if((order = H5Tget_order(hdf_typeid)) < 0)
return NC_EHDFERR;
/* Copy this into the type_info struct. */
if (order == H5T_ORDER_LE)
(*type_info)->endianness = NC_ENDIAN_LITTLE;
else if (order == H5T_ORDER_BE)
(*type_info)->endianness = NC_ENDIAN_BIG;
else /* don't support H5T_ORDER_VAX, H5T_ORDER_MIXED, H5T_ORDER_NONE */
return NC_EBADTYPE;
if(order == H5T_ORDER_LE)
(*type_info)->endianness = NC_ENDIAN_LITTLE;
else if(order == H5T_ORDER_BE)
(*type_info)->endianness = NC_ENDIAN_BIG;
else
return NC_EBADTYPE;
/* Set a class for the type */
/* (Note use of 'NC_INT' for all integer types) */
(*type_info)->nc_type_class = NC_INT;
}
else
{
/* Set a class for the type */
/* (Note use of 'NC_FLOAT' for all floating-point types) */
(*type_info)->nc_type_class = NC_FLOAT;
}
}
if(class == H5T_INTEGER)
(*type_info)->nc_type_class = NC_INT;
else
(*type_info)->nc_type_class = NC_FLOAT;
}
(*type_info)->nc_typeid = nc_type_constant_g[t];
(*type_info)->size = nc_type_size_g[t];
if (!((*type_info)->name = strdup(nc_type_name_g[t])))

View File

@ -1554,11 +1554,11 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
/* Check to see if any unlimited dimensions are used in this var. */
for (d = 0; d < var->ndims; d++) {
for (g = grp; g; g = g->parent)
for (dim = g->dim; dim; dim = dim->l.next)
if (dim->dimid == var->dimids[d])
if (dim->unlimited)
unlimdim++;
for (g = grp; g; g = g->parent)
for (dim = g->dim; dim; dim = dim->l.next)
if (dim->dimid == var->dimids[d])
if (dim->unlimited)
unlimdim++;
}
/* If there are no unlimited dims, and no filters, and the user
@ -1662,7 +1662,7 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
/* At long last, create the dataset. */
name_to_use = var->hdf5_name ? var->hdf5_name : var->name;
LOG((4, "%s: about to H5Dcreate dataset %s of type 0x%x", __func__,
LOG((4, "%s: about to H5Dcreate2 dataset %s of type 0x%x", __func__,
name_to_use, typeid));
if ((var->hdf_datasetid = H5Dcreate2(grp->hdf_grpid, name_to_use, typeid,
spaceid, H5P_DEFAULT, plistid, access_plistid)) < 0)
@ -2295,7 +2295,7 @@ write_var(NC_VAR_INFO_T *var, NC_GRP_INFO_T *grp, nc_bool_t write_dimid)
/* Clear coord. var state transition flags */
var->was_coord_var = NC_FALSE;
var->became_coord_var = NC_FALSE;
/* Now check the attributes for this var. */
if (var->attr_dirty)
{
@ -2364,7 +2364,7 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, nc_bool_t write_dimid)
BAIL(NC_EHDFERR);
/* Create the dataset that will be the dimension scale. */
LOG((4, "%s: about to H5Dcreate a dimscale dataset %s", __func__, dim->name));
LOG((4, "%s: about to H5Dcreate1 a dimscale dataset %s", __func__, dim->name));
if ((dim->hdf_dimscaleid = H5Dcreate1(grp->hdf_grpid, dim->name, H5T_IEEE_F32BE,
spaceid, create_propid)) < 0)
BAIL(NC_EHDFERR);

View File

@ -1454,9 +1454,9 @@ rec_print_metadata(NC_GRP_INFO_T *grp, int tab_count)
strcat(dims_string, temp_string);
}
}
LOG((2, "%s VARIABLE - varid: %d name: %s type: %d ndims: %d dimscale: %d dimids:%s",
LOG((2, "%s VARIABLE - varid: %d name: %s type: %d ndims: %d dimscale: %d dimids:%s endianness: %d, hdf_typeid: %d",
tabs, var->varid, var->name, var->type_info->nc_typeid, var->ndims, (int)var->dimscale,
(dims_string ? dims_string : " -")));
(dims_string ? dims_string : " -"),var->type_info->endianness, var->type_info->native_hdf_typeid));
for(att = var->att; att; att = att->l.next)
LOG((2, "%s VAR ATTRIBUTE - attnum: %d name: %s type: %d len: %d",
tabs, att->attnum, att->name, att->nc_typeid, att->len));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,14 @@
# Some extra tests
SET(NC4_TESTS tst_dims tst_dims2 tst_dims3 tst_files tst_files4 tst_vars
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_xplatform tst_xplatform2 tst_h_atts2 tst_endian_fill tst_atts
tst_xplatform 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_h_scalar tst_rename tst_h_endians)
# Note, renamegroup needs to be compiled before run_grp_rename
build_bin_test(renamegroup)

View File

@ -1,7 +1,7 @@
# This is part of the netCDF package.
# Copyright 2005 University Corporation for Atmospheric Research/Unidata
# See COPYRIGHT file for conditions of use.
#
#
# This entire directory will be skipped if netCDF-4 is not enabled.
#
@ -21,7 +21,7 @@ tst_chunks tst_chunks2 tst_utf8 tst_fills tst_fills2 tst_fillbug \
tst_xplatform tst_xplatform2 tst_h_atts2 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_strbug tst_h_refs \
tst_h_scalar tst_rename
tst_h_scalar tst_rename tst_h_endians
check_PROGRAMS = $(NC4_TESTS) renamegroup
@ -36,7 +36,7 @@ TESTS += run_grp_rename.sh
# If the v2 API was built, add its test program.
if BUILD_V2
check_PROGRAMS += tst_v2
check_PROGRAMS += tst_v2
TESTS += tst_v2
endif # BUILD_V2
@ -76,8 +76,8 @@ TESTS += run_par_bm_test.sh
endif # TEST_PARALLEL
benchmarks: check
./run_bm_radar_2D.sh
./run_bm_radar_2D_compression1.sh
./run_bm_radar_2D.sh
./run_bm_radar_2D_compression1.sh
./run_bm.sh
./run_tst_chunks.sh
./run_bm_ar4.sh
@ -121,7 +121,8 @@ run_bm_ar4.sh ref_tst_compounds.nc run_hdf4_valgrind_tests.sh \
ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc ref_tst_dims.nc \
ref_tst_interops4.nc run_get_knmi_files.sh CMakeLists.txt \
run_grp_rename.sh tst_formatx_hdf4.sh \
run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4
run_chunk_hdf4.sh contiguous.hdf4 chunked.hdf4 \
tst_h_endians.c
CLEANFILES = tst_mpi_parallel.bin cdm_sea_soundings.nc bm_chunking.nc \
bm_radar.nc bm_radar1.nc radar_3d_compression_test.txt \
@ -131,7 +132,7 @@ tst_*.nc tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl \
tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* \
usi_01.* thetau_01.* tst_*.nc tst_*.h5 \
tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
foo1.nc tst_interops2.h4
foo1.nc tst_interops2.h4 tst_h_endians.nc
if USE_HDF4_FILE_TESTS
DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \
@ -140,9 +141,3 @@ MYD29.A2009152.0000.005.2009153124331.hdf \
MYD29.A2002185.0000.005.2007160150627.hdf \
MOD29.A2000055.0005.005.2006267200024.hdf
endif # HDF4_FILE_TESTS

106
nc_test4/tst_h_endians.c Normal file
View File

@ -0,0 +1,106 @@
/*! Test for NCF-331. Added May 11, 2015.
* See the following links for more information:
*
* o Issue on GitHub: https://github.com/Unidata/netcdf-c/issues/112
* o Issue in JIRA: https://bugtracking.unidata.ucar.edu/browse/NCF-331
*
* Test contributed by Jeff Whitaker
*/
#include <string.h>
#include <netcdf.h>
#include <stdio.h>
#include <nc_tests.h>
#include "nc_logging.h"
#define FILE_NAME_NC "tst_h_endians.nc"
#define NDIM 10
#define NLON 20
#define DIM_NAME "x"
#define DIM_LEN 4
#define GRP_NAME "grp"
#define LE_FLOAT_VARNAME "fl_le"
#define BE_FLOAT_VARNAME "fl_be"
#define LE_INT_VARNAME "int_le"
#define BE_INT_VARNAME "int_be"
int main() {
int ncid, dimid;
int le_float_varid;
int be_float_varid;
int le_int_varid;
int be_int_varid;
int ed;
int failures = 0;
int retval = 0;
printf("* Checking that endianness is properly read from file.\n");
printf("** Generating test files.\n");
/*
* 1. Create a netcdf file with endianness as desired.
*/
{
printf("*** Creating a file via netcdf API: %s.\n",FILE_NAME_NC);
retval = nc_create(FILE_NAME_NC, NC_NETCDF4 | NC_CLOBBER, &ncid);
retval = nc_def_dim(ncid, DIM_NAME, NDIM, &dimid);
/* Little-Endian Float */
retval = nc_def_var(ncid, LE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &le_float_varid);
retval = nc_def_var_endian(ncid, le_float_varid, NC_ENDIAN_LITTLE);
/* Big-Endian Float */
retval = nc_def_var(ncid, BE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &be_float_varid);
retval = nc_def_var_endian(ncid, be_float_varid, NC_ENDIAN_BIG);
/* Little-Endian Int */
retval = nc_def_var(ncid, LE_INT_VARNAME, NC_INT, 1, &dimid, &le_int_varid);
retval = nc_def_var_endian(ncid, le_int_varid, NC_ENDIAN_LITTLE);
/* Big-Endian Int */
retval = nc_def_var(ncid, BE_INT_VARNAME, NC_INT, 1, &dimid, &be_int_varid);
retval = nc_def_var_endian(ncid, be_int_varid, NC_ENDIAN_BIG);
retval = nc_close(ncid);
}
/*
* 2. Reopen netcdf-generated file, check to see if the endianness attribute
* exists.
*/
printf("** Checking test files.\n");
{
ncid = 0;
printf("*** %s\n",FILE_NAME_NC);
retval = nc_open(FILE_NAME_NC, NC_NETCDF4 | NC_NOWRITE, &ncid);
retval = nc_inq_varid(ncid,LE_FLOAT_VARNAME,&le_float_varid);
retval = nc_inq_varid(ncid,BE_FLOAT_VARNAME,&be_float_varid);
retval = nc_inq_varid(ncid,LE_INT_VARNAME,&le_int_varid);
retval = nc_inq_varid(ncid,BE_INT_VARNAME,&be_int_varid);
printf("\tLittle-Endian Float...\t");
retval = nc_inq_var_endian(ncid,le_float_varid,&ed);
if(ed == NC_ENDIAN_LITTLE) printf("passed\n"); else {printf("failed\n"); failures++;}
printf("\tBig-Endian Float...\t");
retval = nc_inq_var_endian(ncid,be_float_varid,&ed);
if(ed == NC_ENDIAN_BIG) printf("passed\n"); else {printf("failed\n"); failures++;}
printf("\tLittle-Endian Int...\t");
retval = nc_inq_var_endian(ncid,le_int_varid,&ed);
if(ed == NC_ENDIAN_LITTLE) printf("passed\n"); else {printf("failed\n"); failures++;}
printf("\tBig-Endian Int...\t");
retval = nc_inq_var_endian(ncid,be_int_varid,&ed);
if(ed == NC_ENDIAN_BIG) printf("passed\n"); else {printf("failed\n"); failures++;}
retval = nc_close(ncid);
}
printf("** Failures Returned: [%d]\n",failures);
return failures;
}

View File

@ -5,22 +5,22 @@ add_definitions(-D"TOPSRCDIR=${CMAKE_SOURCE_DIR}")
FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE)
IF(ENABLE_DAP_REMOTE_TESTS)
ADD_EXECUTABLE(nctestserver nctestserver.c)
TARGET_LINK_LIBRARIES(nctestserver netcdf ${ALL_TLL_LIBS})
####
# We have to do a little tweaking
####
# We have to do a little tweaking
# to remove the Release/ and Debug/ directories
# in MSVC builds. This is required to get
# test scripts to work.
####
IF(MSVC)
SET_TARGET_PROPERTIES(nctestserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY
SET_TARGET_PROPERTIES(nctestserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(nctestserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
SET_TARGET_PROPERTIES(nctestserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
${CMAKE_CURRENT_BINARY_DIR})
SET_TARGET_PROPERTIES(nctestserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_CURRENT_BINARY_DIR})
@ -33,7 +33,7 @@ IF(ENABLE_TESTS)
# must be run in a particular order. It is painful but will use macros to help
# keep it from being too bad.
# Binary Test Macro
add_sh_test(ncdap tst_ncdap3)
IF(NOT MSVC)
@ -50,22 +50,22 @@ IF(ENABLE_TESTS)
add_sh_test(ncdap tst_longremote3)
ENDIF()
add_sh_test(ncdap testurl)
add_bin_test(ncdap test_nstride_cached)
add_bin_test(ncdap t_misc)
IF(ENABLE_DAP_AUTH_TESTS)
add_bin_test(ncdap t_auth)
add_sh_test(ncdap testauth)
ENDIF()
add_bin_test(ncdap test_varm3)
###
# This test relates to NCF-330 in
# the Unidata JIRA system.
###
add_bin_test(ncdap t_ncf330)
#add_bin_test(ncdap t_ncf330)
ENDIF()
ENDIF()

View File

@ -45,10 +45,10 @@ test_nstride_cached_SOURCE = test_nstride_cached.c
#t_auth1_SOURCES = t_auth1.c
t_misc_SOURCES = t_misc.c
test_varm3_SOURCES = test_varm3.c
t_ncf330_SOURCES = t_ncf330.c
#t_ncf330_SOURCES = t_ncf330.c
TESTS += test_varm3
TESTS += t_ncf330
#TESTS += t_ncf330
TESTS += test_nstride_cached
TESTS += t_misc