Commit Graph

652 Commits

Author SHA1 Message Date
Dennis Heimbigner
65f866fff6 Fix memory leak
re: Issue https://github.com/Unidata/netcdf-c/issues/2723

H/T to Roland Ambs for finding a memory leak where an allocated
HDF5 plist is not being reclaimed.
2023-07-23 17:25:30 -06:00
Ward Fisher
dc2b0f7608
Merge pull request #2655 from ZedThree/hdf5-transient-types
Add support for HDF5 transient types
2023-07-18 16:49:33 -06:00
Dennis Heimbigner
8cab468169 Suppress filters on variables with non-fixed-size types.
re: Discussion https://github.com/Unidata/netcdf-c/discussions/2554
re: PR https://github.com/Unidata/netcdf-c/pull/2231
re: Issue https://github.com/Unidata/netcdf-c/issues/2189

After some discussion, the issue of applying filters on variables
whose type is not fixed size, was resolved as follows:
1. A call to nc_def_var_filter will ignore such filters, but will issue a log warning.
2. Loading (from an existing file) a variable whose type is not fixed-size and which has filters, will cause the variable to be suppressed.

This PR enforces those rules.

### Misc. Other changes
* Add a test case to test the vlen change.
* Make some minor clean-ups in various cmake and automake files.
* Remove unused test
2023-06-21 14:46:22 -06:00
Dennis Heimbigner
fb40a72b45 Improve performance of the nc_reclaim_data and nc_copy_data functions.
re: Issue https://github.com/Unidata/netcdf-c/issues/2685
re: PR https://github.com/Unidata/netcdf-c/pull/2179

As noted in PR https://github.com/Unidata/netcdf-c/pull/2179,
the old code did not allow for reclaiming instances of types,
nor for properly copying them. That PR provided new functions
capable of reclaiming/copying instances of arbitrary types.

However, as noted by Issue https://github.com/Unidata/netcdf-c/issues/2685, using these
most general functions resulted in a significant performance
degradation, even for common cases.

This PR attempts to mitigate the cost of using the general
reclaim/copy functions in two ways.

First, the previous functions operating at the top level by
using ncid and typeid arguments. These functions were augmented
with equivalent versions that used the netcdf-c library internal
data structures to allow direct access to needed information.
These new functions are used internally to the library.

The second mitigation involves optimizing the internal functions
by providing early tests for common cases. This avoids
unnecessary recursive function calls.

The overall result is a significant improvement in speed by a
factor of roughly twenty -- your mileage may vary. These
optimized functions are still not as fast as the original (more
limited) functions, but they are getting close. Additional optimizations are
possible. But the cost is a significant "uglification" of the
code that I deemed a step too far, at least for now.

## Misc. Changes
1. Added a test case to check the proper reclamation/copy of complex types.
2. Found and fixed some places where nc_reclaim/copy should have been used.
3. Replaced, in the netcdf-c library, (almost all) occurrences of nc_reclaim_copy with calls to NC_reclaim/copy. This plus the optimizations is the primary speed-up mechanism.
4. In DAP4, the metadata is held in a substrate in-memory file; this required some changes so that the reclaim/copy code accessed that substrate dispatcher rather than the DAP4 dispatcher.
5. Re-factored and isolated the code that computes if a type is (transitively) variable-sized or not.
6. Clean up the reclamation code in ncgen; adding the use of nc_reclaim exposed some memory problems.
2023-05-20 17:11:25 -06:00
Dennis Heimbigner
d79f08176a Merge branch 'master' into s3update.dmh 2023-05-09 19:31:18 -06:00
Ben Boeckel
51cfad2dbf hdf5open: check for the H5L info structure version directly 2023-05-05 12:25:40 -04:00
Dennis Heimbigner
49737888ca Improve S3 Documentation and Support
## Improvements to S3 Documentation
* Create a new document *quickstart_paths.md* that give a summary of the legal path formats used by netcdf-c. This includes both file paths and URL paths.
* Modify *nczarr.md* to remove most of the S3 related text.
* Move the S3 text from *nczarr.md* to a new document *cloud.md*.
* Add some S3-related text to the *byterange.md* document.

Hopefully, this will make it easier for users to find the information they want.

## Rebuild NCZarr Testing
In order to avoid problems with running make check in parallel, two changes were made:
1. The *nczarr_test* test system was rebuilt. Now, for each test.
any generated files are kept in a test-specific directory, isolated
from all other test executions.
2. Similarly, since the S3 test bucket is shared, any generated S3 objects
are isolated using a test-specific key path.

## Other S3 Related Changes
* Add code to ensure that files created on S3 are reclaimed at end of testing.
* Used the bash "trap" command to ensure S3 cleanup even if the test fails.
* Cleanup the S3 related configure.ac flag set since S3 is used in several places. So now one should use the option *--enable-s3* instead of *--enable-nczarr-s3*, although the latter is still kept as a deprecated alias for the former.
* Get some of the github actions yml to work with S3; required fixing various test scripts adding a secret to access the Unidata S3 bucket.
* Cleanup S3 portion of libnetcdf.settings.in and netcdf_meta.h.in and test_common.in.
* Merge partial S3 support into dhttp.c.
* Create an experimental s3 access library especially for use with Windows. It is enabled by using the options *--enable-s3-internal* (automake) or *-DENABLE_S3_INTERNAL=ON* (CMake). Also add a unit-test for it.
* Move some definitions from ncrc.h to ncs3sdk.h

## Other Changes
* Provide a default implementation of strlcpy and move this and similar defaults into *dmissing.c*.
2023-04-25 17:15:06 -06:00
Peter Hill
120c4c5320
Merge branch 'main' into hdf5-transient-types
* main: (56 commits)
  Fix a mismatched if,endif block label.
  Update issue with make distcheck
  Update dap4_test for systems without getopt
  Missed unit_test
  Update release notes
  Fix bug in szip handling.
  Update release notes
  "Simplify" XGetopt usage
  added fortran
  documenting logging
  documenting logging
  documenting logging
  Fix issue #2674
  Update to latest main
  ubuntufix1
  ub1"
  bad file reference
  oops
  Maintainer mode should only be turned on prior to minting a release.
  Fix run_jsonconvention.sh to be resilient against irrelevant changes to _NCProperties.
  ...
2023-04-18 09:20:09 +01:00
Ward Fisher
f8904d5a1d
Merge pull request #2675 from uweschulzweida/issue_#2674
Fix issue #2674
2023-04-12 15:48:10 -06:00
uweschulzweida
b0d6fc70b4
Fix issue #2674 2023-04-05 18:05:53 +02:00
Dennis Heimbigner
d7d216a3f5 Merge branch 'master' into dap4tests2.dmh 2023-03-16 14:03:29 -06:00
Ward Fisher
9c388dfd6a
Merge branch 'main' into vfd13.dmh 2023-03-14 11:36:09 -06:00
Peter Hill
03f3eb3ce1
Explicitly ignore HDF5 object references when reading types 2023-03-10 10:19:42 +00:00
Peter Hill
9c18dad567
Add support for HDF5 transient types
These are compound or enum datatypes stored directly in the dataset
itself, and so aren't read as standalone objects during the initial
metadata gathering when the file is opened
2023-03-09 10:11:42 +00:00
Dennis Heimbigner
cf6fcb3b9c Merge branch 'master' into dap4tests2.dmh 2023-03-02 20:00:05 -07:00
Dennis Heimbigner
69e84fe9f1 Fix byterange handling of some URLS
re: Issue

The byterange handling of the following URLS fails.

### Problem 1: "https://crudata.uea.ac.uk/cru/data/temperature/HadCRUT.4.6.0.0.median.nc#mode=bytes"
It turns out that byterange in hdf5 has two possible targets: S3 and not-S3 (e.g. a thredds server or the crudata URL above). Each uses a different HDF5 Virtual File Driver (VFD).
I incorrectly set up the byterange code in libhdf5 so that it would choose one or the other of the two VFD's for any netcdf-c library build. The fix is to allow it to choose either one at run-time.

### Problem 2: "https://noaa-goes16.s3.amazonaws.com/ABI-L1b-RadF/2022/001/18/OR_ABI-L1b-RadF-M6C01_G16_s20220011800205_e20220011809513_c20220011809562.nc#mode=bytes,s3"
When given what appears to be an S3-related URL, the netcdf-c library code converts it into a canonical, so-called "path" format. In casing out the possible input URL formats, I missed the case where the host contains the bucket ("noaa-goes16"), but not the region. So the fix was to check for this case.

## Misc. Related Changes
1. Since S3 is used in more than just NCZarr, I changed the automake/cmake options to replace "--enable-nczarr-s3" with "--enable-s3", but keeping the former option as a synonym for the latter. This also entailed cleaning up libnetcdf.settings WRT S3 support
2. Added the above URLS as additional test cases

## Misc. Un-Related Changes
1. CURLOPT_PUT is deprecated in favor to CURLOPT_UPLOAD
2. Fix some minor warnings

## Open Problems
* Under Ubuntu, either libcrypto or aws-sdk-cpp has a memory leak.
2023-03-02 19:51:02 -07:00
Dennis Heimbigner
6a4ab61fc8 Missed one occurrence of 1,14,0 2023-02-22 15:30:26 -07:00
Dennis Heimbigner
8556a9d634 Extend the dispatch table for H5FD back to version 1.13.2
re: Issue https://github.com/Unidata/netcdf-c/issues/2634
re: PR https://github.com/Unidata/netcdf-c/pull/2615
re: Issue https://github.com/Unidata/netcdf-c/issues/2614

It turns out that the H5FD table change identified in
issue https://github.com/Unidata/netcdf-c/issues/2614
actually occurred in HDF5 version 1.13.2.
Since we do not test with 1.13.x, we did not catch this.
2023-02-22 11:15:43 -07:00
Dennis Heimbigner
295c132789 Fix a distcheck failure with nczarr_test/run_interop.sh
The problem was that files were being copied
into the ${srcdir} rather than ${builddir} directory.
2023-02-17 13:01:11 -07:00
Dennis Heimbigner
727fa74900 Modify H5FDhttp.c to work with HDF5 1.14.0
re: https://github.com/Unidata/netcdf-c/issues/2614

Most of the changes are minor comment changes.
But the dispatch table for H5FD has changed, requiring changes
to H5FDhttp.c, which is derived from the HDF5 source file H5FDstdio.c.
The patch is to conditionally modify the dispatch table
to conform to the HDF5-1.14.0 version.
I was able to build and successfully test 1.14 for a reasonable
set of (non-parallel) ./configure options.
2023-02-10 15:10:43 -07:00
Dennis Heimbigner
591e6b2f6d Fix DAP4 remotetest server
Warning: This PR is a follow on to PR https://github.com/Unidata/netcdf-c/pull/2555 and should not be merged until that prior PR has been merged. The changeset for this PR is a delta on the PR https://github.com/Unidata/netcdf-c/pull/2555.

This PR re-enables the use of the server *remotetest.unidata.ucar.edu/d4ts*
to test several features:
1. Show that access over the Internet to servers using the DAP4 protocol works.
2. Test that DAP4 support in the [Thredds Data Server](https://github.com/Unidata/tds) is operating correctly.
4. Test that the DAP4 support in the [netcdf-java library](https://github.com/Unidata/netcdf-java) library and the DAP4 support in the netcdf-c library are consistent and are interoperable.

The test inputs (primarily *\*.nc* files) provided in the netcdf-c library
are also used by the DAP4 Test Server (aka d4ts) to present web access to a
collection of data files accessible via the DAP4 protocol and which can be
used for testing Internet access to a working server.

To be precise, this version of d4ts is currently in unmerged branches
of the *netcdf-java* and *tds* Github repositories and so are not actually
in the main repositories *yet*. However, the *d4ts.war* file was created
from that branch and used to populate the *remotetest.unidata.ucar.edu*
server

The two other remote servers that were used in the past are *Hyrax* (OPenDAP.org)
and *thredds-test*. These will continue to remain disabled until
those servers can be fixed.

## Primary Changes

* Rebuild the *baselineremote* directory. This directory contains the validation data needed to test the remote servers.
* Re-enable using remotetest.unidata.ucar.edu as part of the DAP4 testing process.
* Fix the *dap4_test/test_remote.sh* test script to match the current available test data.
* Make some changes to libdap4 to improve the ability to catch malformed data streams [affects a lot of files in libdap4].

## Misc. Unrelated Changes

* Remove a raft of warnings, especially in nc_test4/tst_quantize.c.
* Add some additional explanatory information to the NCZarr documentation.
* Cleanup some Doxygen errors in the docs file and reorder some files.
2022-11-15 20:29:21 -07:00
Ward Fisher
5ccb71d7a3
Merge pull request #1701 from magnusuMET/bugfix/musl_build
fix musl build
2022-08-12 15:09:59 -06:00
Dennis Heimbigner
2b45c7ec84 Fix support for reading arrays of HDF5 fixed size strings
re: https://github.com/Unidata/netcdf-c/issues/2159

There was error in libhdf5 that only allowed reading a single
value HDF5 fixed string. Fix to allow reading an array of such strings.
Also make sure it still works for scalars and for attributes.
Add a testcase: nc_test4/tst_fixedstring.sh.
2022-07-29 14:47:07 -06:00
Magnus Ulimoen
670078f981 fix musl build 2022-07-20 08:45:55 +02:00
Edward Hartnett
4e4209b6f0 code and documentation cleanup 2022-07-02 08:13:13 -06:00
Edward Hartnett
309d4bec35 code and documentation cleanup 2022-07-02 07:51:33 -06:00
Edward Hartnett
a2aeec8936 documentation 2022-07-02 06:19:52 -06:00
Edward Hartnett
536cdd28f9 fix and test quantize mode for NC_CLASSIC_MODEL 2022-07-02 06:14:32 -06:00
Dennis Heimbigner
b1600db106 Fix nc_def_var_fletcher32 operation
re: Github Issue https://github.com/Unidata/netcdf-c/issues/2401

The nc_def_var_fletcher32 code in hdf5 is always setting fletcher32
when invoked.
Fix is to properly test value of the fletcher32 argument.
2022-06-13 13:14:55 -06:00
Edward Hartnett
983c74747e fixing issues with dimlens of unlitmited dims in complex situations 2022-05-29 15:22:10 +03:00
Edward Hartnett
08b6ea65a4 fixing parallel I/O bug with dim length for unlimited dimensions 2022-04-26 07:54:47 -06:00
Edward Hartnett
155467ba2d merged master 2022-04-25 10:50:34 -06:00
Ward Fisher
982b258c46 Merge branch 'dimscale_attachement_optional' of https://github.com/gsjaardema/netcdf-c into gh2161.wif 2022-04-19 11:06:34 -06:00
Edward Hartnett
e9ac9bda1c working on parallel numrec problem 2022-04-18 08:22:50 -06:00
Edward Hartnett
60a0f07ccc attempts to get working 2022-04-12 07:52:16 -06:00
Ward Fisher
2ccdf14697 Merge branch 'csz_bitround' of https://github.com/nco/netcdf-c into gh2232.wif 2022-04-01 10:43:34 -06:00
wkliao
826ff7383f use NC_EDIMSCALE for errors related to dimscale 2022-03-25 18:10:52 -05:00
Ward Fisher
cd0f1690e8
Merge pull request #2245 from DennisHeimbigner/filterenhance.dmh 2022-03-21 16:45:27 -06:00
Ward Fisher
d281be2333
Merge branch 'main' into open_mem_truncated_file 2022-03-14 15:02:02 -06:00
Dennis Heimbigner
3ffe7be446 Enhance/Fix filter support
re: Discussion https://github.com/Unidata/netcdf-c/discussions/2214

The primary change is to support so-called "standard filters".
A standard filter is one that is defined by the following
netcdf-c API:
````
int nc_def_var_XXX(int ncid, int varid, size_t nparams, unsigned* params);
int nc_inq_var_XXXX(int ncid, int varid, int* usefilterp, unsigned* params);
````
So for example, zstandard would be a standard filter by defining
the functions *nc_def_var_zstandard* and *nc_inq_var_zstandard*.

In order to define these functions, we need a new dispatch function:
````
int nc_inq_filter_avail(int ncid, unsigned filterid);
````
This function, combined with the existing filter API can be used
to implement arbitrary standard filters using a simple code pattern.
Note that I would have preferred that this function return a list
of all available filters, but HDF5 does not support that functionality.

So this PR implements the dispatch function and implements
the following standard functions:
    + bzip2
    + zstandard
    + blosc
Specific test cases are also provided for HDF5 and NCZarr.
Over time, other specific standard filters will be defined.

## Primary Changes
* Add nc_inq_filter_avail() to netcdf-c API.
* Add standard filter implementations to test use of *nc_inq_filter_avail*.
* Bump the dispatch table version number and add to all the relevant
   dispatch tables (libsrc, libsrcp, etc).
* Create a program to invoke nc_inq_filter_avail so that it is accessible
  to shell scripts.
* Cleanup szip support to properly support szip
  when HDF5 is disabled. This involves detecting
  libsz separately from testing if HDF5 supports szip.
* Integrate shuffle and fletcher32 into the existing
  filter API. This means that, for example, nc_def_var_fletcher32
  is now a wrapper around nc_def_var_filter.
* Extend the Codec defaulting to allow multiple default shared libraries.

## Misc. Changes
* Modify configure.ac/CMakeLists.txt to look for the relevant
  libraries implementing standard filters.
* Modify libnetcdf.settings to list available standard filters
  (including deflate and szip).
* Add CMake test modules to locate libbz2 and libzstd.
* Cleanup the HDF5 memory manager function use in the plugins.
* remove unused file include//ncfilter.h
* remove tests for the HDF5 memory operations e.g. H5allocate_memory.
* Add flag to ncdump to force use of _Filter instead of _Deflate
  or _Shuffle or _Fletcher32. Used for testing.
2022-03-14 12:39:37 -06:00
Ward Fisher
7c113cfae4 Merge branch 'h5align.dmh' of https://github.com/DennisHeimbigner/netcdf-c into gh2206.wif 2022-03-01 09:49:13 -08:00
Charlie Zender
a74d3573e5 First draft of BitRound implementation 2022-02-18 11:00:37 -08:00
Greg Sjaardema
c746c11539
Merge branch 'main' into dimscale_attachement_optional 2022-02-16 11:47:14 -07:00
Dave Allured
d1620e3a75
hdf5set_format_compatibility.c: Function docs.
Comment change only.  Add one paragraph.  Explain the reason for the third argument to H5Pset_libver_bounds.  Simplifies experimental code using advanced features.
2022-02-01 09:58:36 -07:00
Dennis Heimbigner
f3e711e2b8 Add support for setting HDF5 alignment property when creating a file
re: https://github.com/Unidata/netcdf-c/issues/2177
re: https://github.com/Unidata/netcdf-c/pull/2178

Provide get/set functions to store global data alignment
information and apply it when a file is created.

The api is as follows:
````
int nc_set_alignment(int threshold, int alignment);
int nc_get_alignment(int* thresholdp, int* alignmentp);
````

If defined, then for every file created opened after the call to
nc_set_alignment, for every new variable added to the file, the
most recently set threshold and alignment values will be applied
to that variable.

The nc_get_alignment function return the last values set by
nc_set_alignment.  If nc_set_alignment has not been called, then
it returns the value 0 for both threshold and alignment.

The alignment parameters are stored in the NCglobalstate object
(see below) for use as needed. Repeated calls to nc_set_alignment
will overwrite any existing values in NCglobalstate.

The alignment parameters are applied in libhdf5/hdf5create.c
and libhdf5/hdf5open.c

The set/get alignment functions are defined in libsrc4/nc4internal.c.

A test program was added as nc_test4/tst_alignment.c.

## Misc. Changes Unrelated to Alignment

* The NCRCglobalstate type was renamed to NCglobalstate to
  indicate that it represented more general global state than
  just .rc data.  It was also moved to nc4internal.h.  This led
  to a large number of small changes: mostly renaming. The
  global state management functions were moved to nc4internal.c.

* The global chunk cache variables have been moved into
  NCglobalstate.  As warranted, other global state will be moved
  as well.

* Some misc. problems with the nczarr performance tests were corrected.
2022-01-29 15:27:52 -07:00
Dennis Heimbigner
89cc20a20d Rename GranularBitGroom to GranularBitRound
As per Charlie Zender's request (https://github.com/Unidata/netcdf-c/pull/2197#issuecomment-1022762863), the GranularBitGroom name is changed to GranularBitRound
with attendant code changes.
2022-01-28 13:04:16 -07:00
Ward Fisher
41baf43aef Merge branch 'format-compat-on-reopen' of https://github.com/Dave-Allured/netcdf-c into Dave-Allured-format-compat-on-reopen 2022-01-21 08:54:34 -07:00
Ward Fisher
abcbd9e1d5
Merge pull request #2156 from edwardhartnett/ejh_t1
Now setting deflate_level of 0 is interpreted to mean no deflate.
2022-01-18 17:02:30 -07:00
Ward Fisher
3980d7616a
Merge pull request #2130 from nco/csz_gbg
Granular BitGroom feature for netcdf-c
2022-01-13 17:35:16 -07:00
Dave Allured
158f290663
Minor comment fix for return codes 2022-01-12 19:06:17 -07:00