Commit Graph

598 Commits

Author SHA1 Message Date
Sean McBride
e188eb95d2 Fixed -Wunused-variable warnings 2024-11-15 23:25:21 -05:00
Dennis Heimbigner
ef425b9171 ckp 2024-09-30 14:39:48 -06:00
Dennis Heimbigner
9abe3cb961 Fix bug in run_newformat.sh
Problem was basically that the test file ref_oldformat.zip
was incorrect. Additionally, logic in zsync.c was incorrect.

### Misc. other fixes
1. Turn off accidental debug output
2024-08-13 20:53:04 -06:00
Ward Fisher
f8164e3b73
Merge pull request #2917 from MehdiChinoune/ci-mingw
CI: Setup a CMake job for MSYS2/MinGW
2024-05-14 17:26:43 -07:00
Dennis Heimbigner
69ed78e7d7 Convert the ENABLE_XXX options to NETCDF_ENABLE_XXX options
# Primary Change
In order to conform to the cmake overhaul, occurrences of
ENABLE_XXX options in the nczarr code have been changed to
NETCDF_ENABLE_XXX.

# Misc. Other changes
* Fix use of rand_s in libdispatch/ncrandom.c
* Fix some bugs in the mingw gitub action.
* Fix signature bug in libncpoco/cp_win32.c
* Make some NCZarr fixes to config.h.cmake.in
2024-05-11 16:23:40 -06:00
مهدي شينون (Mehdi Chinoune)
c5c2d931cc CMake: Fix running tests on MinGW 2024-05-07 04:44:54 +01:00
Ward Fisher
c26f7eabf4 Refactor macro _FillValue to NC_FillValue in support of https://github.com/Unidata/netcdf-c/issues/2858 2024-04-24 11:38:07 -06:00
Ward Fisher
38d3831319
Merge branch 'main' into clang-tidy-fixes 2024-04-02 15:30:47 -06:00
Ward Fisher
e5b83cd70f
Merge pull request #2884 from ZedThree/silence-test-warnings
Fix warnings in tests and examples
2024-03-21 17:13:04 -06:00
Kyle Shores
6d1bae4de9 Replace ENABLE_EXTERNAL_SERVER_TESTS with NETCDF_ENABLE_EXTERNAL_SERVER_TESTS 2024-03-18 15:51:35 -05:00
Kyle Shores
2bce1e6776 Replace ENABLE_CDF5 with NETCDF_ENABLE_CDF5 2024-03-18 15:51:04 -05:00
Kyle Shores
b4eb8bf019 Replace ENABLE_BYTERANGE with NETCDF_ENABLE_BYTERANGE 2024-03-18 15:50:57 -05:00
Kyle Shores
dc4830a632 replacing BUILD_UTILITIES 2024-03-18 15:29:24 -05:00
Peter Hill
3e70c8133f
Fix warnings in nc_test 2024-03-12 16:13:40 +00:00
Peter Hill
83e184bc75
Link nc_test against third-party libraries
Ensures pnetcdf include directory is in path
2024-03-12 09:59:30 +00:00
Ward Fisher
cc1494d988
Merge branch 'main' into awsdfalt.dmh 2024-03-05 12:50:08 -07:00
Sean McBride
fa7f751b97 Manually fixed some bugprone-assert-side-effect warnings 2024-03-01 20:46:58 -05:00
Sean McBride
fb5c6b139c Auto fixed clang-tidy readability-uppercase-literal-suffix warnings 2024-03-01 20:46:58 -05:00
Sean McBride
4188db2817 Auto fixed clang-tidy readability-redundant-control-flow warnings 2024-03-01 20:46:58 -05:00
Sean McBride
0d82e3cd28 Auto fixed clang-tidy bugprone-suspicious-string-compare warnings 2024-03-01 20:46:58 -05:00
Ward Fisher
42b3f5582e Added a comment block for future reference. 2024-01-22 12:37:35 -08:00
Julien Schueller
5537a60885 CMake: Add support for UNITY_BUILD 2024-01-12 10:18:29 +01:00
Ward Fisher
c1fb4b0bae
Merge pull request #2809 from ZedThree/silence-malloc-warnings
Silence conversion warnings from `malloc` arguments
2023-12-21 17:20:56 -07:00
Sean McBride
adc4dc1435 Replaced some sprintf with snprintf with aid of new variable containing size
One case required slightly complicated accounting of how much space is left in the buffer.
2023-12-08 13:30:38 -05:00
Sean McBride
dfc2ac7296 Replaced trivial uses of sprintf with snprintf
In all these cases the size of the buffer can be computed with sizeof.
2023-12-08 13:30:38 -05:00
Dennis Heimbigner
a068be1907 replace some missing files 2023-12-03 15:09:10 -07:00
Dennis Heimbigner
27f615bebc Properly handle missing regions in URLS
NOTE: it is important that this fix gets into 4.9.3

re: Issue https://github.com/Unidata/netcdf-c/issues/2798

## Modifications
* This PR includes PR https://github.com/Unidata/netcdf-c/pull/2813
* Support the following AWS environment variables in the internal S3 library
  (they are already supported by aws-sdk-cpp).
  - AWS_REGION
  - AWS_DEFAULT_REGION
  - AWS_ACCESS_KEY_ID
  - AWS_CONFIG_FILE
  - AWS_PROFILE
  - AWS_SECRET_ACCESS_KEY
  - (source https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html).
* Support an empty region when specifying s3.amazonaws.com as the host.
* Move some S3/AWS related functions to ds3util.c
* Add a test case to test empty region and AWS_[DEFAULT]_REGION.
2023-12-02 21:03:59 -07:00
Peter Hill
d07dac918c
Silence conversion warnings from malloc arguments
Mostly just add an explicit cast when calling `malloc` and its
variants. Sometimes instead change the type of a local variable if
this would silence multiple warnings.
2023-11-24 18:20:52 +00:00
Ward Fisher
16841a990d
Merge pull request #2782 from ZedThree/fix-float-conversions
Fix most float conversion warnings
2023-11-14 10:42:29 -07:00
Ward Fisher
9593dbfac9
Merge pull request #2790 from seanm/mmap-bsd
Renamed mmap variable, which conflicts with mmap() function on FreeBSD
2023-11-06 14:48:06 -07:00
Sean McBride
fb62738f72 Renamed mmap variable, which conflicts with mmap() function on FreeBSD
This fixes compiler errors on FreeBSD 14.
2023-11-06 16:05:24 -05:00
Peter Hill
763e54f8a1
Fix most float conversion warnings
Fixes ~200 out of ~240 `-Wfloat-conversion` warnings on gcc 13.2
2023-10-26 16:01:24 +01:00
Dennis Heimbigner
df3636b959 Mitigate S3 test interference + Unlimited Dimensions in NCZarr
This PR started as an attempt to add unlimited dimensions to NCZarr.
It did that, but this exposed significant problems with test interference.
So this PR is mostly about fixing -- well mitigating anyway -- test
interference.

The problem of test interference is now documented in the document docs/internal.md.
The solutions implemented here are also describe in that document.
The solution is somewhat fragile but multiple cleanup mechanisms
are provided. Note that this feature requires that the
AWS command line utility must be installed.

## Unlimited Dimensions.
The existing NCZarr extensions to Zarr are modified to support unlimited dimensions.
NCzarr extends the Zarr meta-data for the ".zgroup" object to include netcdf-4 model extensions. This information is stored in ".zgroup" as dictionary named "_nczarr_group".
Inside "_nczarr_group", there is a key named "dims" that stores information about netcdf-4 named dimensions. The value of "dims" is a dictionary whose keys are the named dimensions. The value associated with each dimension name has one of two forms
Form 1 is a special case of form 2, and is kept for backward compatibility. Whenever a new file is written, it uses format 1 if possible, otherwise format 2.
* Form 1: An integer representing the size of the dimension, which is used for simple named dimensions.
* Form 2: A dictionary with the following keys and values"
   - "size" with an integer value representing the (current) size of the dimension.
   - "unlimited" with a value of either "1" or "0" to indicate if this dimension is an unlimited dimension.

For Unlimited dimensions, the size is initially zero, and as variables extend the length of that dimension, the size value for the dimension increases.
That dimension size is shared by all arrays referencing that dimension, so if one array extends an unlimited dimension, it is implicitly extended for all other arrays that reference that dimension.
This is the standard semantics for unlimited dimensions.

Adding unlimited dimensions required a number of other changes to the NCZarr code-base. These included the following.
* Did a partial refactor of the slice handling code in zwalk.c to clean it up.
* Added a number of tests for unlimited dimensions derived from the same test in nc_test4.
* Added several NCZarr specific unlimited tests; more are needed.
* Add test of endianness.

## Misc. Other Changes
* Modify libdispatch/ncs3sdk_aws.cpp to optionally support use of the
   AWS Transfer Utility mechanism. This is controlled by the
   ```#define TRANSFER```` command in that file. It defaults to being disabled.
* Parameterize both the standard Unidata S3 bucket (S3TESTBUCKET) and the netcdf-c test data prefix (S3TESTSUBTREE).
* Fixed an obscure memory leak in ncdump.
* Removed some obsolete unit testing code and test cases.
* Uncovered a bug in the netcdf-c handling of big-endian floats and doubles. Have not fixed yet. See tst_h5_endians.c.
* Renamed some nczarr_tests testcases to avoid name conflicts with nc_test4.
* Modify the semantics of zmap\#ncsmap_write to only allow total rewrite of objects.
* Modify the semantics of zodom to properly handle stride > 1.
* Add a truncate operation to the libnczarr zmap code.
2023-09-26 16:56:48 -06:00
Dennis Heimbigner
c4ecdd6403 Fix a number of minor bugs
1. Fix a shift bug in ncexhash.c (Issue https://github.com/Unidata/netcdf-c/issues/2702)
2. Fix an S3 related error in test_byterange.sh
3. Fix bz2/bzip2 handling in configure.ac
2023-07-24 16:20:26 -06:00
Dennis Heimbigner
98477b9f25 ## Addendum [5/9/23]
It turns out that attempting to test S3 using a github action secret is a very complex process. So, this was disabled for github actions. However, a new *run_tests_s3.yml* action file was added that will eventually encapsulate S3 testing.
2023-05-09 21:13:49 -06: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
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
Ward Fisher
1d908e29ac Explicit cast to unsigned char. 2023-02-24 13:37:28 -07:00
Ward Fisher
0c45c39607 More issues returned by sanitizer, related to attempts to assign MAX_UNSIGNED_CHAR (255) to a variable of type char. 2023-02-24 11:48:00 -07:00
Ward Fisher
7762823483 Correct another uninitialized issue. 2023-02-21 16:58:28 -07:00
Ward Fisher
df7f6ec571 Correct undefined variable error. 2023-02-21 16:54:51 -07:00
Ward Fisher
5ae3655436 Fixing issues uncovered by compiling with '-fsanitize=undefined' and running nc_test/nc_test, in support of https://github.com/Unidata/netcdf-c/issues/1983, amongst others. The cast as was being used was undefined behavior, and had to be worked around in a style approximating C++'s 'reinterpret_cast' 2023-02-21 15:02:14 -07:00
Dennis Heimbigner
1a45ee025f Fix some addtional errors in NCZarr
re: Issue https://github.com/Unidata/netcdf-c/issues/2502

H/T Charlie Zender

* Fix NCZarr handling of endianness value NC_ENDIAN_NATIVE. This now matches how it is handled in libhdf5
* Fix NCZarr handling of char typed attribute with value "". This now matches how it is handled in libhdf5
* Add test for various char attribute values
* Change the mapping of NC_CHAR and NC_STRING to dtype; requires changing some test files also.
* Optimize the testing for NC_ENOTBUILT in NC_open.
* Turn off debugging left on accidentally
* Fix memory leak in tst_pnetcdf.c
* Fix blosc test
2022-09-09 14:25:24 -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
f3426bc7d9 Updated CMakeLists to avoid the error described in https://github.com/Unidata/netcdf-c/issues/2271 2022-06-29 14:44:49 -06:00
Ward Fisher
dfc47497e3 Make pnetcdf tests run in serial fashion when using cmake 2022-06-28 16:53:38 -06:00
Ward Fisher
baaa2b6f00 Building test programs invoked by run_pnetcdf_tests.sh 2022-06-28 15:28:40 -06:00
Ward Fisher
bfca030037 Fixing cmake-based run_pnetcdf_tests.sh 2022-06-28 15:04:58 -06:00
Ward Fisher
f987c94a70 Corrected Makefile.am error. 2022-06-10 14:17:51 -06:00
Ward Fisher
5e3e79e26b Make dist is generating a distribution with missing files, that only cmake seems to complain about. 2022-06-10 14:16:16 -06:00