Skip to content

Commit db41b2a

Browse files
authored
Merge pull request #868 from Unidata/gh849.wif
Pull #849 plus a note in the release notes.
2 parents 3f035d9 + a3ea416 commit db41b2a

28 files changed

+2289
-655
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ ENDIF()
447447
###
448448

449449
# Option to use HDF4
450-
OPTION(ENABLE_HDF4 "Build netCDF-4 with HDF5 read capability(HDF4, HDF5 and Zlib required)." OFF)
450+
OPTION(ENABLE_HDF4 "Build netCDF-4 with HDF4 read capability(HDF4, HDF5 and Zlib required)." OFF)
451451
IF(ENABLE_HDF4)
452452
SET(USE_HDF4 ON)
453453
# Check for include files, libraries.
@@ -526,6 +526,11 @@ IF(ENABLE_NETCDF_4)
526526
SET(USE_NETCDF4 ON CACHE BOOL "")
527527
SET(ENABLE_NETCDF_4 ON CACHE BOOL "")
528528
SET(ENABLE_NETCDF4 ON CACHE BOOL "")
529+
ELSE()
530+
SET(USE_HDF4_FILE_TESTS OFF)
531+
SET(USE_HDF4 OFF)
532+
SET(ENABLE_HDF4_FILE_TESTS OFF)
533+
SET(ENABLE_HDF4 OFF)
529534
ENDIF()
530535

531536
# Option to allow for strict null file padding.
@@ -1609,6 +1614,10 @@ IF(USE_HDF5)
16091614
add_subdirectory(libsrc4)
16101615
ENDIF(USE_HDF5)
16111616

1617+
IF(USE_HDF4)
1618+
add_subdirectory(libhdf4)
1619+
ENDIF(USE_HDF4)
1620+
16121621
IF(ENABLE_DAP2)
16131622
ADD_SUBDIRECTORY(oc2)
16141623
ADD_SUBDIRECTORY(libdap2)

Makefile.am

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ if USE_PNETCDF
6262
LIBSRCP = libsrcp
6363
endif
6464

65+
# Build HDF4 if desired.
66+
if USE_HDF4
67+
LIBHDF4 = libhdf4
68+
endif
69+
6570
# Define Test directories
6671
if BUILD_TESTSETS
6772
TESTDIRS = $(V2_TEST) nc_test $(NC_TEST4) $(NCDAP2TESTDIR) \
@@ -72,8 +77,8 @@ endif
7277
# and run. ncgen must come before ncdump, because their tests
7378
# depend on it.
7479
SUBDIRS = include $(H5_TEST_DIR) libdispatch libsrc $(LIBSRC4_DIR) \
75-
$(LIBSRCP) $(OCLIB) $(DAP2) ${DAP4} liblib $(NCGEN3) $(NCGEN) \
76-
$(NCDUMP) $(TESTDIRS) docs $(EXAMPLES)
80+
$(LIBSRCP) $(LIBHDF4) $(OCLIB) $(DAP2) ${DAP4} liblib $(NCGEN3) \
81+
$(NCGEN) $(NCDUMP) $(TESTDIRS) docs $(EXAMPLES)
7782

7883
# Remove these generated files, for a distclean.
7984
DISTCLEANFILES = VERSION comps.txt test_prog libnetcdf.settings \

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This file contains a high-level description of this package's evolution. Release
88
## 4.6.1 - TBD
99

1010
* [Bug Fix] Improved support for CRT builds with Visual Studio, improves zlib detection in hdf5 library. See [Github #853](https://github.com/Unidata/netcdf-c/pull/853) for more information.
11+
* [Enhancement][Internal] Moved HDF4 into a distinct dispatch layer. See [Github #849](https://github.com/Unidata/netcdf-c/pull/849) for more information.
1112

1213
## 4.6.0 - January 24, 2018
1314
* [Enhancement] Full support for using HDF5 dynamic filters, both for reading and writing. See the file docs/filters.md.

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ AC_MSG_CHECKING([whether reading of HDF4 SD files is to be enabled])
207207
AC_ARG_ENABLE([hdf4], [AS_HELP_STRING([--enable-hdf4],
208208
[build netcdf-4 with HDF4 read capability (HDF4, HDF5 and zlib required)])])
209209
test "x$enable_hdf4" = xyes || enable_hdf4=no
210+
if test "x$enable_hdf4" = xyes -a "x$enable_netcdf_4" = xno; then
211+
AC_MSG_ERROR([NetCDF-4 is required for HDF4 features])
212+
fi
210213
AC_MSG_RESULT($enable_hdf4)
211214

212215
# Does the user want to turn on extra HDF4 file tests?
@@ -1447,6 +1450,7 @@ AC_CONFIG_FILES([Makefile
14471450
oc2/Makefile
14481451
libdap2/Makefile
14491452
libdap4/Makefile
1453+
libhdf4/Makefile
14501454
libdispatch/Makefile
14511455
liblib/Makefile
14521456
ncdump/cdl/Makefile

include/Makefile.am

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# This automake file generates the Makefile to build the include
55
# directory.
66

7+
# Ed Hartnett, Dennis Heimbigner, Ward Fisher
8+
79
include_HEADERS = netcdf.h netcdf_meta.h
810

911
if BUILD_PARALLEL
@@ -14,12 +16,12 @@ if BUILD_DISKLESS
1416
include_HEADERS += netcdf_mem.h
1517
endif
1618

17-
noinst_HEADERS = nc_logging.h nc_tests.h fbits.h nc.h \
18-
nclist.h ncuri.h ncutf8.h ncdispatch.h ncdimscale.h \
19-
netcdf_f.h err_macros.h ncbytes.h nchashmap.h ceconstraints.h rnd.h \
20-
nclog.h ncconfigure.h nc4internal.h nctime.h nc3internal.h \
21-
onstack.h nc_hashmap.h ncrc.h ncauth.h ncoffsets.h nctestserver.h \
22-
nc4dispatch.h nc3dispatch.h ncexternl.h ncwinpath.h ncfilter.h
19+
noinst_HEADERS = nc_logging.h nc_tests.h fbits.h nc.h nclist.h \
20+
ncuri.h ncutf8.h ncdispatch.h ncdimscale.h netcdf_f.h err_macros.h \
21+
ncbytes.h nchashmap.h ceconstraints.h rnd.h nclog.h ncconfigure.h \
22+
nc4internal.h nctime.h nc3internal.h onstack.h nc_hashmap.h ncrc.h \
23+
ncauth.h ncoffsets.h nctestserver.h nc4dispatch.h nc3dispatch.h \
24+
ncexternl.h ncwinpath.h ncfilter.h hdf4dispatch.h
2325

2426
if USE_DAP
2527
noinst_HEADERS += ncdap.h

include/hdf4dispatch.h

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,276 @@
1+
/* Copyright 2018, UCAR/Unidata. See netcdf/COPYRIGHT file for copying
2+
* and redistribution conditions. */
3+
/**
4+
* @file
5+
* This header file contains the prototypes for the HDF4 versions
6+
* of the netCDF functions.
7+
*
8+
* Ed Hartnett
9+
*/
10+
#ifndef _HDF4DISPATCH_H
11+
#define _HDF4DISPATCH_H
12+
13+
#include "config.h"
14+
#include <stddef.h> /* size_t, ptrdiff_t */
15+
#include <errno.h> /* netcdf functions sometimes return system errors */
16+
#include "ncdispatch.h"
17+
18+
#if defined(__cplusplus)
19+
extern "C" {
20+
#endif
21+
22+
extern int
23+
HDF4_create(const char *path, int cmode,
24+
size_t initialsz, int basepe, size_t *chunksizehintp,
25+
int useparallel, void* parameters,
26+
NC_Dispatch*, NC*);
27+
28+
extern int
29+
HDF4_open(const char *path, int mode,
30+
int basepe, size_t *chunksizehintp,
31+
int use_parallel, void* parameters,
32+
NC_Dispatch*, NC*);
33+
34+
extern int
35+
HDF4_redef(int ncid);
36+
37+
extern int
38+
HDF4__enddef(int ncid, size_t h_minfree, size_t v_align,
39+
size_t v_minfree, size_t r_align);
40+
41+
extern int
42+
HDF4_sync(int ncid);
43+
44+
extern int
45+
HDF4_abort(int ncid);
46+
47+
extern int
48+
HDF4_close(int ncid);
49+
50+
extern int
51+
HDF4_set_fill(int ncid, int fillmode, int *old_modep);
52+
53+
extern int
54+
HDF4_set_base_pe(int ncid, int pe);
55+
56+
extern int
57+
HDF4_inq_base_pe(int ncid, int *pe);
58+
59+
extern int
60+
HDF4_inq_format(int ncid, int *formatp);
61+
62+
extern int
63+
HDF4_inq_format_extended(int ncid, int *formatp, int *modep);
64+
65+
extern int
66+
HDF4_inq(int ncid, int *ndimsp, int *nvarsp, int *nattsp, int *unlimdimidp);
67+
68+
extern int
69+
HDF4_inq_type(int, nc_type, char *, size_t *);
70+
71+
/* Begin _dim */
72+
73+
extern int
74+
HDF4_def_dim(int ncid, const char *name, size_t len, int *idp);
75+
76+
extern int
77+
HDF4_inq_dimid(int ncid, const char *name, int *idp);
78+
79+
extern int
80+
HDF4_inq_dim(int ncid, int dimid, char *name, size_t *lenp);
81+
82+
extern int
83+
HDF4_inq_unlimdim(int ncid, int *unlimdimidp);
84+
85+
extern int
86+
HDF4_rename_dim(int ncid, int dimid, const char *name);
87+
88+
/* End _dim */
89+
/* Begin _att */
90+
91+
extern int
92+
HDF4_inq_att(int ncid, int varid, const char *name,
93+
nc_type *xtypep, size_t *lenp);
94+
95+
extern int
96+
HDF4_inq_attid(int ncid, int varid, const char *name, int *idp);
97+
98+
extern int
99+
HDF4_inq_attname(int ncid, int varid, int attnum, char *name);
100+
101+
extern int
102+
HDF4_rename_att(int ncid, int varid, const char *name, const char *newname);
103+
104+
extern int
105+
HDF4_del_att(int ncid, int varid, const char*);
106+
107+
/* End _att */
108+
/* Begin {put,get}_att */
109+
110+
extern int
111+
HDF4_get_att(int ncid, int varid, const char *name, void *value, nc_type);
112+
113+
extern int
114+
HDF4_put_att(int ncid, int varid, const char *name, nc_type datatype,
115+
size_t len, const void *value, nc_type);
116+
117+
/* End {put,get}_att */
118+
/* Begin _var */
119+
120+
extern int
121+
HDF4_def_var(int ncid, const char *name,
122+
nc_type xtype, int ndims, const int *dimidsp, int *varidp);
123+
124+
extern int
125+
HDF4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
126+
int *ndimsp, int *dimidsp, int *nattsp,
127+
int *shufflep, int *deflatep, int *deflate_levelp,
128+
int *fletcher32p, int *contiguousp, size_t *chunksizesp,
129+
int *no_fill, void *fill_valuep, int *endiannessp,
130+
unsigned int* idp, size_t* nparamsp, unsigned int* params
131+
);
132+
133+
extern int
134+
HDF4_inq_varid(int ncid, const char *name, int *varidp);
135+
136+
extern int
137+
HDF4_rename_var(int ncid, int varid, const char *name);
138+
139+
extern int
140+
HDF4_put_vara(int ncid, int varid,
141+
const size_t *start, const size_t *count,
142+
const void *value, nc_type);
143+
144+
extern int
145+
HDF4_get_vara(int ncid, int varid,
146+
const size_t *start, const size_t *count,
147+
void *value, nc_type);
148+
149+
/* End _var */
150+
151+
/* netCDF4 API only */
152+
extern int
153+
HDF4_var_par_access(int, int, int);
154+
155+
extern int
156+
HDF4_inq_ncid(int, const char *, int *);
157+
158+
extern int
159+
HDF4_inq_grps(int, int *, int *);
160+
161+
extern int
162+
HDF4_inq_grpname(int, char *);
163+
164+
extern int
165+
HDF4_inq_grpname_full(int, size_t *, char *);
166+
167+
extern int
168+
HDF4_inq_grp_parent(int, int *);
169+
170+
extern int
171+
HDF4_inq_grp_full_ncid(int, const char *, int *);
172+
173+
extern int
174+
HDF4_inq_varids(int, int * nvars, int *);
175+
176+
extern int
177+
HDF4_inq_dimids(int, int * ndims, int *, int);
178+
179+
extern int
180+
HDF4_inq_typeids(int, int * ntypes, int *);
181+
182+
extern int
183+
HDF4_inq_type_equal(int, nc_type, int, nc_type, int *);
184+
185+
extern int
186+
HDF4_def_grp(int, const char *, int *);
187+
188+
extern int
189+
HDF4_rename_grp(int, const char *);
190+
191+
extern int
192+
HDF4_inq_user_type(int, nc_type, char *, size_t *, nc_type *,
193+
size_t *, int *);
194+
195+
extern int
196+
HDF4_def_compound(int, size_t, const char *, nc_type *);
197+
198+
extern int
199+
HDF4_insert_compound(int, nc_type, const char *, size_t, nc_type);
200+
201+
extern int
202+
HDF4_insert_array_compound(int, nc_type, const char *, size_t,
203+
nc_type, int, const int *);
204+
205+
extern int
206+
HDF4_inq_typeid(int, const char *, nc_type *);
207+
208+
extern int
209+
HDF4_inq_compound_field(int, nc_type, int, char *, size_t *,
210+
nc_type *, int *, int *);
211+
212+
extern int
213+
HDF4_inq_compound_fieldindex(int, nc_type, const char *, int *);
214+
215+
extern int
216+
HDF4_def_vlen(int, const char *, nc_type base_typeid, nc_type *);
217+
218+
extern int
219+
HDF4_put_vlen_element(int, int, void *, size_t, const void *);
220+
221+
extern int
222+
HDF4_get_vlen_element(int, int, const void *, size_t *, void *);
223+
224+
extern int
225+
HDF4_def_enum(int, nc_type, const char *, nc_type *);
226+
227+
extern int
228+
HDF4_insert_enum(int, nc_type, const char *, const void *);
229+
230+
extern int
231+
HDF4_inq_enum_member(int, nc_type, int, char *, void *);
232+
233+
extern int
234+
HDF4_inq_enum_ident(int, nc_type, long long, char *);
235+
236+
extern int
237+
HDF4_def_opaque(int, size_t, const char *, nc_type *);
238+
239+
extern int
240+
HDF4_def_var_deflate(int, int, int, int, int);
241+
242+
extern int
243+
HDF4_def_var_fletcher32(int, int, int);
244+
245+
extern int
246+
HDF4_def_var_chunking(int, int, int, const size_t *);
247+
248+
extern int
249+
HDF4_def_var_fill(int, int, int, const void *);
250+
251+
extern int
252+
HDF4_def_var_endian(int, int, int);
253+
254+
extern int
255+
HDF4_def_var_filter(int, int, unsigned int, size_t, const unsigned int*);
256+
257+
extern int
258+
HDF4_set_var_chunk_cache(int, int, size_t, size_t, float);
259+
260+
extern int
261+
HDF4_get_var_chunk_cache(int, int, size_t *, size_t *, float *);
262+
263+
extern int
264+
HDF4_inq_unlimdims(int, int *, int *);
265+
266+
extern int
267+
HDF4_show_metadata(int);
268+
269+
extern int
270+
HDF4_initialize(void);
271+
272+
#if defined(__cplusplus)
273+
}
274+
#endif
275+
276+
#endif /*_HDF4DISPATCH_H */

include/nc4internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ int nc4_type_free(NC_TYPE_INFO_T *type);
399399
int nc4_nc4f_list_add(NC *nc, const char *path, int mode);
400400
int nc4_var_add(NC_VAR_INFO_T **var);
401401
int nc4_var_del(NC_VAR_INFO_T *var);
402+
int nc4_vararray_add(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var);
402403
int nc4_dim_list_add(NC_DIM_INFO_T **list, NC_DIM_INFO_T **dim);
403404
int nc4_dim_list_del(NC_DIM_INFO_T **list, NC_DIM_INFO_T *dim);
404405
int nc4_att_list_add(NC_ATT_INFO_T **list, NC_ATT_INFO_T **att);

0 commit comments

Comments
 (0)