Commit Graph

28 Commits

Author SHA1 Message Date
Dennis Heimbigner
6abaab967b Fix some problems with PR https://github.com/Unidata/netcdf-c/pull/2492
re: PR https://github.com/Unidata/netcdf-c/pull/2492
re: Issue https://github.com/Unidata/netcdf-c/issues/2494

This PR fixes some problems with the pull request https://github.com/Unidata/netcdf-c/pull/2492 in response to Issue https://github.com/Unidata/netcdf-c/issues/2494.

* Found and fixed more scalar handling problems and add a test case for scalars.
* Cleanup nczarr_test/run_string.sh test
* Document *_nczarr_default_maxstrlen* and *_nczarr_maxstrlen*.

* Support both "Nan" and *Nan* as being floating point constants
  for attributes. It is unclear from the Zarr V2 spec if
  unquoted *Nan* is legal or not, but support for reading.
  Write the quoted versions when writing an attribute.  Similar
  for Infinity constants.
  So NCZarr supports the following constants for use in Attributes
    * *Nan*, "Nan", *-Nan*, "-Nan"
    * *Nanf*, "Nanf", *-Nanf*, "-Nanf"
    * *Infinity*, "Infinity", *-Infinity*, "-Infinity"
    * *Infinityf*, "Infinityf", *-Infinityf*, "-Infinityf"
2022-09-03 14:21:48 -06:00
Dennis Heimbigner
231ae96c4b Add support for Zarr string type to NCZarr
* re: https://github.com/Unidata/netcdf-c/pull/2278
* re: https://github.com/Unidata/netcdf-c/issues/2485
* re: https://github.com/Unidata/netcdf-c/issues/2474

This PR subsumes PR https://github.com/Unidata/netcdf-c/pull/2278.
Actually is a bit an omnibus covering several issues.

## PR https://github.com/Unidata/netcdf-c/pull/2278
Add support for the Zarr string type.
Zarr strings are restricted currently to be of fixed size.
The primary issue to be addressed is to provide a way for user to
specify the size of the fixed length strings. This is handled by providing
the following new attributes special:
1. **_nczarr_default_maxstrlen** —
This is an attribute of the root group. It specifies the default
maximum string length for string types. If not specified, then
it has the value of 64 characters.
2. **_nczarr_maxstrlen** —
This is a per-variable attribute. It specifies the maximum
string length for the string type associated with the variable.
If not specified, then it is assigned the value of
**_nczarr_default_maxstrlen**.

This PR also requires some hacking to handle the existing netcdf-c NC_CHAR
type, which does not exist in zarr. The goal was to choose numpy types for
both the netcdf-c NC_STRING type and the netcdf-c NC_CHAR type such that
if a pure zarr implementation read them, it would still work and an
NC_CHAR type would be handled by zarr as a string of length 1.

For writing variables and NCZarr attributes, the type mapping is as follows:
* "|S1" for NC_CHAR.
* ">S1" for NC_STRING && MAXSTRLEN==1
* ">Sn" for NC_STRING && MAXSTRLEN==n

Note that it is a bit of a hack to use endianness, but it should be ok since for
string/char, the endianness has no meaning.

For reading attributes with pure zarr (i.e. with no nczarr
atribute types defined), they will always be interpreted as of
type NC_CHAR.

## Issue: https://github.com/Unidata/netcdf-c/issues/2474
This PR partly fixes this issue because it provided more
comprehensive support for Zarr attributes that are JSON valued expressions.
This PR still does not address the problem in that issue where the
_ARRAY_DIMENSION attribute is incorrectly set. Than can only be
fixed by the creator of the datasets.

## Issue: https://github.com/Unidata/netcdf-c/issues/2485
This PR also fixes the scalar failure shown in this issue.
It generally cleans up scalar handling.
It also adds a note to the documentation describing that
NCZarr supports scalars while Zarr does not and also how
scalar interoperability is achieved.

## Misc. Other Changes
1. Convert the nczarr special attributes and keys to be all lower case. So "_NCZARR_ATTR" now used "_nczarr_attr. Support back compatibility for the upper case names.
2. Cleanup my too-clever-by-half handling of scalars in libnczarr.
2022-08-27 20:21:13 -06:00
Ward Fisher
d6dee0c8ca Add libxml2 install to mingw GitHub actions. 2022-06-21 17:05:47 -06:00
Ward Fisher
5f1e18b83d Add manual GitHub actions triggers for the tests. 2022-06-13 16:56:22 -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
b1b59e1760 Correct trigger event for mingw tests to pull_request from push' 2022-01-24 16:31:34 -07:00
Ward Fisher
a8c5307ed3 Removing cmake-based tests for now. 2022-01-24 16:23:42 -07:00
Ward Fisher
16115303a5 Missing pipe character. 2022-01-24 16:15:57 -07:00
Ward Fisher
05e207f5ca Syntax error. 2022-01-24 16:12:11 -07:00
Ward Fisher
acbbde16a1 Syntax error. 2022-01-24 16:10:51 -07:00
Ward Fisher
db98c57af6 HDF5 configuration diagnostic output 2022-01-24 16:09:39 -07:00
Ward Fisher
472e4c8b36 Oh right, Unix Makefiles 2022-01-24 16:02:45 -07:00
Ward Fisher
3058b760ad Force CMake to use gcc 2022-01-24 15:59:10 -07:00
Ward Fisher
7e1c770dff Adding hdf5 info for cmake-based tests. 2022-01-24 15:55:13 -07:00
Ward Fisher
f12eb2d0f9 Moving on to cmake-based github actions. 2022-01-24 15:47:27 -07:00
Ward Fisher
27db0f2354 More tweaks. 2022-01-24 15:21:29 -07:00
Ward Fisher
3c017da5e3 Collapse build and run test steps into a single step, no need to build all the tests before seeing if any fail. 2022-01-24 15:11:58 -07:00
Ward Fisher
3898d4f80a Remove stray text. 2022-01-24 13:18:05 -07:00
Ward Fisher
84070ad177 Next iteration of compilation test. 2022-01-24 13:08:55 -07:00
Ward Fisher
08598a761f Additional compilation work. 2022-01-24 12:20:04 -07:00
Ward Fisher
e8e3141cb1 Really simplify things. 2022-01-24 11:45:46 -07:00
Ward Fisher
0333da7be5 Clean up some Unix-related cruft. 2022-01-24 11:38:21 -07:00
Ward Fisher
ddd675a6d7 Temporarily disable cache 2022-01-24 11:30:14 -07:00
Ward Fisher
d0ad57fb3e Further developments unfolding. 2022-01-24 11:24:45 -07:00
Ward Fisher
d76fbe3fc2 Remove stray text. 2022-01-24 11:06:21 -07:00
Ward Fisher
3a12cee940 Working on MinGW/MSYS2 support. Attempting workflow with system-installed libhdf5 2022-01-24 11:05:33 -07:00
Ward Fisher
a6e7ad17a2 Added cmake to the mingw-based test. 2022-01-24 10:54:00 -07:00
Ward Fisher
4ad9f00493 Add skeleton mingw/msys2 Github CI tests. 2022-01-24 10:51:19 -07:00