Skip to content

Commit

Permalink
Merge branch 'main' into plistfix.dmh
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Jul 25, 2023
2 parents 65f866f + db2519c commit 8a45d26
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 50 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This file contains a high-level description of this package's evolution. Release
## 4.9.3 - TBD

* Fix memory leak WRT unreclaimed HDF5 plist. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
* Support HDF5 transient types when reading an HDF5 file. See [Github #2724](https://github.com/Unidata/netcdf-c/pull/2724).
* Suppress filters on variables with non-fixed-size types. See [Github #2716](https://github.com/Unidata/netcdf-c/pull/2716).
* Provide a single option to disable all network access and testing. See [Github #2708](https://github.com/Unidata/netcdf-c/pull/2708).
* Fix some problems with earthdata authorization and data access. See [Github #2709](https://github.com/Unidata/netcdf-c/pull/2709).
Expand Down
2 changes: 1 addition & 1 deletion dap4_test/baseline/test_vlen4.nc.d4d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ types:
v1_f1_t f1(2) ;
}; // v1_t
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
v1_t v1 ;
data:
Expand Down
2 changes: 1 addition & 1 deletion dap4_test/baseline/test_vlen4.nc.d4m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ types:
v1_f1_t f1(2) ;
}; // v1_t
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
v1_t v1 ;
}
4 changes: 2 additions & 2 deletions dap4_test/baseline/test_vlen4.nc.d4p
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
xmlns="http://xml.opendap.org/ns/DAP/4.0#"
xmlns:dap="http://xml.opendap.org/ns/DAP/4.0#">
<Dimensions>
<Dimension name="_Anonymous2" size="2"/>
<Dimension name="_AnonymousDim2" size="2"/>
</Dimensions>
<Types>
<Structure name="v1">
<Seq name="f1" type="/v1_f1_t">
<Dim name="/_Anonymous2"/>
<Dim name="/_AnonymousDim2"/>
</Sequence>
</Structure>
<Structure name="v1_f1_base">
Expand Down
6 changes: 3 additions & 3 deletions dap4_test/baselinehyrax/amsre_20060131v5.dat.hyrax
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
netcdf amsre_20060131v5 {
dimensions:
_Anonymous3 = 3 ;
_Anonymous6 = 6 ;
_AnonymousDim3 = 3 ;
_AnonymousDim6 = 6 ;
variables:
byte time_a(_Anonymous3, _Anonymous6) ;
byte time_a(_AnonymousDim3, _AnonymousDim6) ;
string time_a:Equator_Crossing_Time = "1:30 PM" ;
data:

Expand Down
2 changes: 1 addition & 1 deletion dap4_test/baselineraw/test_vlen4.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ types:
v1_f1_t f1(2) ;
}; // v1_t
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
v1_t v1 ;
data:
Expand Down
12 changes: 6 additions & 6 deletions dap4_test/baselineremote/test_atomic_array.1.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ netcdf test_atomic_array {
types:
opaque(16) opaque16_t ;
dimensions:
_Anonymous1 = 1 ;
_Anonymous2 = 2 ;
_AnonymousDim1 = 1 ;
_AnonymousDim2 = 2 ;
variables:
ubyte vu8(_Anonymous1, _Anonymous2) ;
double vd(_Anonymous1) ;
string vs(_Anonymous1, _Anonymous1) ;
opaque16_t vo(_Anonymous1, _Anonymous1) ;
ubyte vu8(_AnonymousDim1, _AnonymousDim2) ;
double vd(_AnonymousDim1) ;
string vs(_AnonymousDim1, _AnonymousDim1) ;
opaque16_t vo(_AnonymousDim1, _AnonymousDim1) ;

// global attributes:
string :_dap4.ce = "/vu8[1][0:2:2];/vd[1];/vs[1][0];/vo[0][1]" ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_atomic_array.2.nc.ncdump
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
netcdf test_atomic_array {
dimensions:
_Anonymous3 = 3 ;
_AnonymousDim3 = 3 ;
variables:
short v16(_Anonymous3) ;
short v16(_AnonymousDim3) ;

// global attributes:
string :_dap4.ce = "/v16[0:1,3]" ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_atomic_array.3.nc.ncdump
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
netcdf test_atomic_array {
dimensions:
_Anonymous3 = 3 ;
_AnonymousDim3 = 3 ;
variables:
short v16(_Anonymous3) ;
short v16(_AnonymousDim3) ;

// global attributes:
string :_dap4.ce = "/v16[3,0:1]" ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_enum_array.6.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ types:
Altocumulus = 7, Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10,
Missing = 127} ;
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
cloud_class_t primary_cloud(_Anonymous2) ;
cloud_class_t primary_cloud(_AnonymousDim2) ;
cloud_class_t primary_cloud:_FillValue = Missing ;

// global attributes:
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_one_vararray.4.nc.ncdump
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
netcdf test_one_vararray {
dimensions:
_Anonymous1 = 1 ;
_AnonymousDim1 = 1 ;
variables:
int t(_Anonymous1) ;
int t(_AnonymousDim1) ;

// global attributes:
string :_dap4.ce = "/t[1]" ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_one_vararray.5.nc.ncdump
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
netcdf test_one_vararray {
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
int t(_Anonymous2) ;
int t(_AnonymousDim2) ;

// global attributes:
string :_dap4.ce = "/t[0:1]" ;
Expand Down
6 changes: 3 additions & 3 deletions dap4_test/baselineremote/test_opaque_array.7.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ netcdf test_opaque_array {
types:
opaque(16) opaque16_t ;
dimensions:
_Anonymous1 = 1 ;
_Anonymous2 = 2 ;
_AnonymousDim1 = 1 ;
_AnonymousDim2 = 2 ;
variables:
opaque16_t vo2(_Anonymous1, _Anonymous2) ;
opaque16_t vo2(_AnonymousDim1, _AnonymousDim2) ;

// global attributes:
string :_dap4.ce = "/vo2[1][0:1]" ;
Expand Down
4 changes: 2 additions & 2 deletions dap4_test/baselineremote/test_struct_array.8.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ types:
int y ;
}; // s_t
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
s_t s(_Anonymous2, _Anonymous2) ;
s_t s(_AnonymousDim2, _AnonymousDim2) ;

// global attributes:
string :_dap4.ce = "/s[0:2:3][0:1]" ;
Expand Down
2 changes: 1 addition & 1 deletion dap4_test/baselineremote/test_vlen4.nc.ncdump
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ types:
v1_f1_t f1(2) ;
}; // v1_t
dimensions:
_Anonymous2 = 2 ;
_AnonymousDim2 = 2 ;
variables:
v1_t v1 ;
data:
Expand Down
8 changes: 4 additions & 4 deletions dap4_test/baselinethredds/2004050300_eta_211.nc.thredds
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
netcdf \2004050300_eta_211 {
dimensions:
record = UNLIMITED ; // (1 currently)
_Anonymous1 = 1 ;
_Anonymous4 = 4 ;
_Anonymous15 = 15 ;
_AnonymousDim1 = 1 ;
_AnonymousDim4 = 4 ;
_AnonymousDim15 = 15 ;
variables:
double reftime(record) ;
string reftime:units = "hours since 1992-1-1" ;
string reftime:long_name = "reference time" ;
double valtime(record) ;
string valtime:units = "hours since 1992-1-1" ;
string valtime:long_name = "valid time" ;
float Z_sfc(_Anonymous1, _Anonymous4, _Anonymous15) ;
float Z_sfc(_AnonymousDim1, _AnonymousDim4, _AnonymousDim15) ;
string Z_sfc:navigation = "nav" ;
float Z_sfc:_FillValue = -9999.006f ;
string Z_sfc:units = "gp m" ;
Expand Down
1 change: 1 addition & 0 deletions include/hdf5internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct NCauth;
/** Struct to hold HDF5-specific info for the file. */
typedef struct NC_HDF5_FILE_INFO {
hid_t hdfid;
unsigned transientid; /* counter for transient ids */
NCURI* uri; /* Parse of the incoming path, if url */
#if defined(ENABLE_BYTERANGE)
int byterange;
Expand Down
6 changes: 5 additions & 1 deletion include/netcdf_filter_hdf5_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "config.h"
#endif

#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

/* Support headers */
#include <netcdf.h>
#include <netcdf_filter.h>
Expand Down Expand Up @@ -142,7 +146,7 @@ typedef const void* (*H5PL_get_plugin_info_proto)(void);
#define H5MM_realloc realloc
#endif
#ifndef H5MM_xfree
#define H5MM_xfree nullfree
#define H5MM_xfree(x) do{if((x)!=NULL) free(x);}while(0)
#endif
#ifndef H5_ATTR_UNUSED
#define H5_ATTR_UNUSED
Expand Down
2 changes: 1 addition & 1 deletion libdap4/d4parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ makeAnonDim(NCD4parser* parser, const char* sizestr)

ret = parseLL(sizestr,&size);
if(ret) return NULL;
snprintf(name,NC_MAX_NAME,"/_Anonymous%lld",size);
snprintf(name,NC_MAX_NAME,"/_AnonymousDim%lld",size);
/* See if it exists already */
dim = lookupFQN(parser,name,NCD4_DIM);
if(dim == NULL) {/* create it */
Expand Down
34 changes: 27 additions & 7 deletions libhdf5/hdf5open.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,8 @@ get_type_info2(NC_GRP_INFO_T *h5_grp, hid_t datasetid, NC_TYPE_INFO_T **type_inf
if (type == NULL) {
/* If we still can't read the type, ignore it, it probably
* means this object is a reference */
if (read_type(h5_grp, native_typeid, ""))
if (read_type(h5_grp, native_typeid, NULL))
return NC_EBADTYPID;

if((type = nc4_rec_find_hdf_type(h5, native_typeid)))
*type_info = type;
}
Expand Down Expand Up @@ -1981,7 +1980,7 @@ hdf5free(void* memory)
*
* @param grp Pointer to group info struct.
* @param hdf_typeid HDF5 type ID.
* @param type_name Pointer that gets the type name.
* @param type_name Pointer that gets the type name; NULL => anonymous
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
Expand All @@ -1993,19 +1992,26 @@ hdf5free(void* memory)
static int
read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
{
NC_TYPE_INFO_T *type;
NC_HDF5_TYPE_INFO_T *hdf5_type;
NC_FILE_INFO_T *h5 = NULL;
NC_TYPE_INFO_T *type = NULL;
NC_HDF5_FILE_INFO_T *hdf5_info = NULL;
NC_HDF5_TYPE_INFO_T *hdf5_type = NULL;
H5T_class_t class;
hid_t native_typeid;
size_t type_size;
int nmembers;
int retval;
char transientname[NC_MAX_NAME];

assert(grp && type_name);
assert(grp);

LOG((4, "%s: type_name %s grp->hdr.name %s", __func__, type_name,
LOG((4, "%s: type_name %s grp->hdr.name %s", __func__, (type_name?type_name:"NULL"),
grp->hdr.name));

/* Get HDF5-specific object info. */
h5 = (NC_FILE_INFO_T *)grp->nc4_info;
hdf5_info = (NC_HDF5_FILE_INFO_T*)h5->format_file_info;

/* What is the class of this type, compound, vlen, etc. */
if ((class = H5Tget_class(hdf_typeid)) < 0)
return NC_EHDFERR;
Expand All @@ -2023,6 +2029,20 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
return NC_EHDFERR;
LOG((5, "type_size %d", type_size));

if(type_name == NULL) {
/* This is a transient/anonymous type, so generate a name for it */
const char* suffix = NULL; /* class */
switch (class) {
case H5T_ENUM: suffix = "Enum"; break;
case H5T_COMPOUND: suffix = "Compound"; break;
case H5T_VLEN: suffix = "Vlen"; break;
case H5T_OPAQUE: suffix = "Opaque"; break;
default: suffix = "Unknown"; break;
}
snprintf(transientname,sizeof(transientname),"_Anonymous%s%u",suffix,++hdf5_info->transientid);
type_name = transientname;
}

/* Add to the list for this new type, and get a local pointer to it. */
if ((retval = nc4_type_list_add(grp, type_size, type_name, &type)))
return retval;
Expand Down
19 changes: 12 additions & 7 deletions nc_test4/tst_h_transient_types.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,14 @@ main()

printf("*** Checking accessing file through netCDF-4 API...");
{
int ncid, varid, enumid;
int i, ncid, varid, enumid;
complex read_z;
int num_types, class;
int *typeids;
nc_type base_nc_type;
char name[NC_MAX_NAME];
size_t size, nfields;
bool read_b;
int num_types;


nc_set_log_level(4);
nc_set_log_level(0); /* Report HDF5 errors */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;

/* Read known types */
Expand All @@ -97,7 +94,15 @@ main()
typeids = (int*)malloc((size_t)num_types * sizeof(int));
if (nc_inq_typeids(ncid, NULL, typeids)) ERR;

if (nc_inq_user_type(ncid, typeids[0], name, &size, &base_nc_type, &nfields, &class)) ERR;
/* Verify transient names */
for(i=0;i<num_types;i++) {
if (nc_inq_user_type(ncid, typeids[i], name, NULL, NULL, NULL, NULL)) ERR;
if(strlen(name) == 0) {
fprintf(stderr,"Transient type has no name\n");
ERR;
}
fprintf(stderr,"type: %s\n",name);
}
free(typeids);

/* Verify that the dataset is present */
Expand Down
3 changes: 3 additions & 0 deletions plugins/H5Zblosc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ extern "C" {
#endif

#include "netcdf_filter_build.h"

#ifdef HAVE_BLOSC
#include "blosc.h"
#endif

#ifdef _MSC_VER
#ifdef DLL_EXPORT /* define when building the library */
Expand Down
2 changes: 2 additions & 0 deletions plugins/H5Zzstd.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef H5ZSTD_H
#define H5ZSTD_H

#ifdef HAVE_ZSTD
#include "zstd.h"
#endif

#ifdef _MSC_VER
#ifdef DLL_EXPORT /* define when building the library */
Expand Down

0 comments on commit 8a45d26

Please sign in to comment.