Commit Graph

480 Commits

Author SHA1 Message Date
Ward Fisher
cb321fa0db Fix a few issues related to detection of libhdf4. 2024-06-04 16:15:49 -06:00
Dennis Heimbigner
f0f0f39950 Cleanup various Zarr-related build issues
# Description
Remove various obsolete build options. Also do some code movement.

## Specific Changes

* The remotetest server is sometimes unstable, so provide a mechanism
  to force disabling calls to remotetest.unidata.ucar.edu.
  This is enabled by adding a repository variable named
  REMOTETESTDOWN with the value "yes".
* Fix CMakeLists.txt to use the uname command as an alternate
  to using the hostname command (which does not work under cygwin).
* Remove the JNA stuff as obsolete
* Remove the ENABLE_CLIENTSIDE_FILTERS options since it has been
  disabled for a while.
* Fix bad option flag in some github action .yml files: change --disable-xml2 to --disable-libxml2
* Collect globalstate definitions into nc4internal.h
* Remove ENABLE_NCZARR_FILTERS_TESTING option as obsolete and replace
  with ENABLE_NCZARR_FILTERS
* Move some dispatcher independent functions from libsrc4/nc4internal.c to libdispatch/ddispatch.c
* As a long term goal, and because it is now the case that --enable-nczarr
    => USE_NETCDF4, make the external options --enable-netcdf-4 and
    --enable-netcdf4 obsolete in favor of --enable-hdf5
    We will do the following for one more release cycle.
        1. Make --enable-netcdf-4 be an alias for --enable-netcdf4.
        2. Make --enable-netcdf4 an alias for --enable-hdf5.
        3. Internally, convert most uses of USE_NETCDF_4 ad USE_NETCDF4 to USE_HDF5
    After the next release, --enable-netcdf-4 and --enable-netcdf4 will
    be removed.
2024-05-15 18:46:25 -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
Ward Fisher
ebd3f36a9a Modify CMakeLists.txt to honor CMAKE_INSTALL_MANDIR in support of https://github.com/Unidata/netcdf-c/issues/2920. 2024-05-07 16:46:43 -06:00
مهدي شينون (Mehdi Chinoune)
c5c2d931cc CMake: Fix running tests on MinGW 2024-05-07 04:44:54 +01:00
Ward Fisher
e19558c982 Merge Unidata/netcdf-c:main into branch to take advantage of Windows runner-based CI on github actions. 2024-04-18 16:42:35 -06:00
Ward Fisher
38d3831319
Merge branch 'main' into clang-tidy-fixes 2024-04-02 15:30:47 -06:00
Peter Hill
9315ca101a
Merge branch 'main' into silence-ncgen-warnings
* main: (107 commits)
  Updated Release Notes.
  A bit of cleanup for now, more to follow, but moving on to other roadblocks.
  Comment out debugging messages, will remove before final merge.  Clean up the logic, remove some rough edges.
  Add a filter to process options and report deprecation warning.
  Remove dangling define in netcdf_meta.h template file.
  No effect other than to remove a personal annoyance I introduced in the first place.
  Updated the nc-config script with the following:
  adding deprecation error for usage of NETCDF_ENABLE_NETCDF4
  removing cmake alias variable for netcdf4
  removing script
  replacing something that removes semicolons
  another one
  fixing some that were missing?
  removing variables
  Replacing NC_USE_STATIC_CRT with NETCDF_USE_STATIC_CRT
  Replace NC_FIND_SHARED_LIBS with NETCDF_FIND_SHARED_LIBS
  Replace ENABLE_XGETOPT with NETCDF_ENABLE_XGETOPT
  Replace ENABLE_UNIT_TESTS with NETCDF_ENABLE_UNIT_TESTS
  Replace ENABLE_TESTS with NETCDF_ENABLE_TESTS
  Replace ENABLE_STRICT_NULL_BYTE_HEADER_PADDING with NETCDF_ENABLE_STRICT_NULL_BYTE_HEADER_PADDING
  ...
2024-03-25 09:25:25 +00:00
Peter Hill
0d354152ca
Silence some conversion warnings in ncgen generated files 2024-03-25 09:25:24 +00:00
Peter Hill
c74b78efc6
Fix return type of listlength 2024-03-25 09:25:24 +00:00
Peter Hill
320c29c723
Fix more sign conversion warnings in ncgen 2024-03-25 09:25:24 +00:00
Peter Hill
47d1b68599
Cast to correct type in assignment 2024-03-25 09:25:24 +00:00
Peter Hill
3134af3ce7
Remove unused static variable 2024-03-25 09:25:24 +00:00
Peter Hill
17a7b28301
Change type of opaque object length member 2024-03-25 09:25:24 +00:00
Peter Hill
6b17d77e7a
Fix some size/conversion warnings in ncgen.l/y 2024-03-25 09:25:24 +00:00
Peter Hill
ad8b7b74b6
Remove unused function from ncgen/dump.c 2024-03-25 09:25:23 +00:00
Peter Hill
a90730c402
Try to be more consistent in char type for escaping characters 2024-03-25 09:25:23 +00:00
Peter Hill
506a09df7e
Try to be more consistent with types of alignments/offsets 2024-03-25 09:25:23 +00:00
Peter Hill
c1977cacc9
Fix some sign conversion warnings in ncgen 2024-03-25 09:25:23 +00:00
Peter Hill
c244ed6683
Use char consistently for fillchar in genchar.c 2024-03-25 09:25:23 +00:00
Peter Hill
57e754f579
Silence lots conversion warnings in ncgen 2024-03-25 09:25:23 +00:00
Peter Hill
83faffacaa
Change type of string length member
Fixes lots of sign-conversion warnings
2024-03-25 09:25:23 +00:00
Peter Hill
6c249365f0
Change bbAppendn argument type to size_t
Fixes lots of warnings about conversions changing value
2024-03-25 09:25:18 +00:00
Ward Fisher
cdd9cbb83c Merging current main development branch, changing option name to include
NETCDF_ prefix. Thanks!

Merge remote-tracking branch 'upstream/main' into cmake-ncgen-generate
2024-03-21 14:08:12 -06:00
Kyle Shores
2bce1e6776 Replace ENABLE_CDF5 with NETCDF_ENABLE_CDF5 2024-03-18 15:51:04 -05:00
Peter Hill
baf8108b56
CMake: Fix outdated comment for ncgen generation 2024-03-12 13:36:19 +00:00
Peter Hill
f4a909a86e
Merge branch 'main' into cmake-ncgen-generate
* main: (209 commits)
  Bump Visual Studio appveyor, for the brief period before we swap out to GitHub actions.
  Make a change in support of https://github.com/Unidata/netcdf-c/pull/2879
  Revert "fix cmake build with ENABLE_HDF4 and hdf requiring jpeg"
  removing need for global compile definition
  fix cmake build with ENABLE_HDF4 and hdf requiring jpeg
  Removed assumption that we are linking against static HDF5 when building a static library. While it's reasonable to provide a mechanism to specify this, it is not necessarily true. We should also perhaps rename the NC_FIND_SHARED option, since LIBS implies it will look for static or shared libraries for all dependencies, but this logic only looks for HDF5. In any case, commenting this out for now until we can rework it.
  Re-adding global add-definition for the time being.  Its lack introduces an unnecessary roadblock (at the moment).  Re-formulated logic for determining what tests to run when.  Need to figure out why plugins are turned off when MINGW is true, but that's a different issue.  As of this push, all tests succeed on local windows system.
  Update cmake-based plugins and test logic.
  Modify messages to be more clear.
  setting dll export on each target
  Correct lingering compilation issue under Visual Studio. Hopefully I haven't broken the Linux build
  Addressing a handful of issues encountered in Visual Studio re: linking, setting compiler flags for VC, etc.
  removing c++ header file from c header
  Corrected a dependencies issue linking against libcurl and finding curl/curl.h using Visual Studio.  There's another issue to correct, but this is getting us a lot closer.
  Correct(?) syntax with target_compile_options() in top level CMakeLists.txt.  Correct the logic flow in libncxml/CMakeLists.txt to not try to include non-existant directory when libxml2 is not found.
  removing unused cmake
  updating tests to use correct cmake variable
  removing possibly redundant cmake for shared library
  updating release notes
  bumping cmake version
  ...
2024-03-12 13:16:53 +00:00
Sean McBride
029389efcb Auto fixed clang-tidy readability-redundant-declaration warnings 2024-03-01 20:46:58 -05:00
Sean McBride
c92381721e Manually fixed some bugprone-suspicious-semicolon warnings 2024-03-01 20:46:58 -05:00
Sean McBride
dededdf2ee Manually fixed some bugprone-unsafe-functions warnings 2024-03-01 20:46:58 -05:00
Sean McBride
d5d24f756f Manually fixed some bugprone-not-null-terminated-result 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
Ward Fisher
25fc13bd80
Merge pull request #2840 from ZedThree/silence-ncdump-warnings
Silence ncdump warnings
2024-02-09 16:49:01 -07:00
Orion Poplawski
07134b9581 Fix some variable types. Resolves #2849 2024-01-29 22:05:11 -07:00
Ward Fisher
42b3f5582e Added a comment block for future reference. 2024-01-22 12:37:35 -08:00
Peter Hill
b6eb730684
Silence various conversion warnings in ncdump 2024-01-15 15:46:13 +00: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
Peter Hill
630099b65f
CMake: Add missing dependency on ncgen.y/l 2023-12-11 11:48:11 +00:00
Peter Hill
6d6f1a82a0
CMake: Add option to always automatically regenerate ncgen source
Also:
- ensure `flex` and `bison` are available
- run commands from top level directory so `#line` directives in
  generated files include the `ncgen` subdirectory -- gives better
  tracing of warnings
- include `sed` commands for fixing filename in `#line` directives
2023-12-11 10:57:58 +00: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
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
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
Ward Fisher
9459f92f1f
Merge branch 'main' into dap4tests1.dmh 2023-04-11 16:23:48 -06:00
Dennis Heimbigner
3765d86e46 "Simplify" XGetopt usage
When "getopt()" is not available, various of the netcdf-c utilities
use XGetopt instead. This occurs primarily when building under Window,
so the build changes are restricted to CMake.

This PR tries to isolate XGetopt.c to the libdispatch directory
and then builds the various utilities using this cliche:
````
IF(USE_X_GETOPT)
  SET(XGETOPTSRC "${CMAKE_CURRENT_SOURCE_DIR}/../libdispatch/XGetopt.c")
ENDIF()
````

This avoids the need to copy XGetopt.c to all the directories that
use it.
2023-04-09 13:10:41 -06:00
Dennis Heimbigner
835b81a285 Cleanup DAP4 testing
NOTE: This PR should not be included in 4.9.1 since additional
DAP4 related PRs will be forthcoming.

This PR makes major changes to libdap4 and dap4_test driven by changes to TDS.

* Enable DAP4
* Clean up the test input files and the test baseline comparison files. This entails:
    * Remove a multitude of unused test input and baseline data files; among them are dap4_test/: daptestfiles, dmrtestfiles, nctestfiles, and misctestfiles.
    * Define a canonical set of test input files and record in dap4_test/cdltestfiles.
    * Use the cdltestfiles to generate the .nc test inputs. This set of .nc files is then moved to the d4ts (DAP4 test server) war file in the tds repository. This set then becomes the canonical set of DAP4 test sources.
    * Scrape d4ts to obtain copies of the raw streams of DAP4 encoded data. The .dmr and .dap streams are then stored in dap4_test/rawtestfiles.
    * Disable some remote server tests until those servers are fixed.
* Add an option to ncdump (-XF) that forces the type of the _FillValue attribute; this is primarily to simplify testing of fill mismatch.
* Minor bug fixes to ncgen.
* Changes to libdap4:
    * Replace old checksum hack with the dap4.checksum flag.
    * Support the dap4.XXX controls.
    * Cleanup _FillValue handling, especially var-attribute type mismatches.
    * Fix enum handling based on changes to netcdf-java.
* Changes to dap4_test:
    * Add getopt support to various test support programs.
    * Remove unneeded shell scripts.
    * Add new scripts: test_curlopt.sh
2022-11-13 13:15:11 -07:00
Ward Fisher
3edcdc240b Correct a typo in support of https://github.com/Unidata/netcdf-c/issues/2534 2022-10-26 09:22:50 -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