Skip to content

Port netcdf c 3093#260

Open
ajelenak wants to merge 5 commits into
masterfrom
port-netcdf-c-3093
Open

Port netcdf c 3093#260
ajelenak wants to merge 5 commits into
masterfrom
port-netcdf-c-3093

Conversation

@ajelenak

Copy link
Copy Markdown
Contributor
  • Port netcdf-c PR #3093 -- all quantization loops in ccr_bgr() and
    ccr_gbr() now skip ±0.0 and NaN.
  • Include also ±Inf.
  • Tests for these special values.

ajelenak and others added 3 commits June 9, 2026 22:18
Port netcdf-c PR #3093 -- all quantization loops in ccr_bgr() and
ccr_gbr() now skip ±0.0 and NaN via (val != 0.0 && !isnan(val)),
superseding the bit-pattern u*_ptr[idx] != 0U checks that only caught
+0.0. The has_mss_val == 0 fallback now uses NaN as a no-op sentinel
(NC_FILL_FLOAT/DOUBLE macros dropped).
The loop bodies have well-defined behavior only for finite inputs:
BitRound's per-value bit-shift becomes an out-of-range shift on ±Inf
(undefined behavior), and BitGroom's loop turns ±Inf bit patterns
into NaN by ORing low mantissa bits. Both guards now use isfinite(val)
instead of !isnan(val) to block ±Inf in addition to NaN. New h5filter_specials_{bitround,bitgroom} round-trip tests
write NaN, ±Inf, ±0.0, and normal values via H5Pset_filter, read back,
and assert in C that the special values pass through unchanged while
at least one normal value was quantized.
Comment thread BITGROOM/example/CMakeLists.txt Outdated
Comment thread BITGROOM/example/CMakeLists.txt Outdated
#include "hdf5.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, standard header files should come first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved up.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I still see hdf5.h included first...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is outdated commit maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread BITGROOM/example/h5filter_specials_bitgroom.c Outdated
Comment thread BITGROOM/example/h5filter_specials_bitgroom.c Outdated
@bmribler bmribler self-requested a review June 24, 2026 19:44
ret = 0;

done:
if (dset_id > 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H5I_INVALID_HID is recommended for comparison. Same for lines 133, 135, 197, 199, and 201. There may be other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants