Commit Graph

615 Commits

Author SHA1 Message Date
Dennis Heimbigner
06498ff16a various fixes 2019-05-23 16:35:03 -06:00
Dennis Heimbigner
6ebc108f00 Nccopy was overriding default chunking when it should not.
re: issue https://github.com/Unidata/netcdf-c/issues/1398
re: esupport NDY-294972

The new chunking code added to nccopy missed one case.
In the event that there are no chunking specifications
of any kind, and the input is not netcdf-4, and the output
is netcdf-4 and must be chunked, then use the default chunking
that the library computes as part of the nc_def_var() function.

Misc. changes:
1. add some chunking debug code to hdf5var.c
2019-05-21 15:59:27 -06:00
Ward Fisher
c776039eba Updated call to NC4_read_provenance. 2019-04-18 10:53:16 -06:00
Ed Hartnett
af84c8d023
Merge branch 'master' into ejh_non_contoversial 2019-03-16 18:08:49 -06:00
Dennis Heimbigner
2420b69a83 Fix nccopy to use NC_PERSIST so that -w actually persists the output.
re: Issue https://github.com/Unidata/netcdf-c/issues/1365

At some point (4.6.1) we changed the diskless handling of flags
and added a new NC_PERSIST flag. Looks like we did not fix all
occurrences of the old flag set, specifically for 'nccopy -w' command.
Also added some tests (tst_nccopy_w{3,4}.sh) for this situation.
2019-03-15 12:05:27 -06:00
Ed Hartnett
c88253677a clean up 2019-03-12 09:54:16 -06:00
Dennis Heimbigner
88a7a1753c Simplify libhdf5/nc5info.c to move to lazy parsing
re: https://github.com/Unidata/netcdf-c/issues/1352

When nc4info.c encounters an _NCProperties attribute
with a version number it does not recognize, it does not
show it correctly.

Solution chosen is to arrange so that accessing the attribute
returns the raw value of the Attribute from the file. This way,
even if the version is unrecognized, it will return something
usable.

The changes were primarily to never attempt to parse the value
of _NCProperties until actually required. Which since they
are currently not used means that parsing never occurs.

Also modified ncdump/tst_fileinfo.sh to include some extra testing

I tested the original failure by changing the value of NCPROPS to 3.
However, there is no way to test this at build time.

Misc. Changes
* Inlined the provenance info in the NC_FILE_INFO_T structure
* Centralized stuff from elsewhere into include/nc_provenance.h

Misc. Unrelated Changes
* Removed/turned off some misc debug output left on by accident
* Fix CPPFLAGS name error in libhdf5/Makefile.am
2019-03-09 20:35:57 -07:00
Ward Fisher
c0d24c827b
Merge pull request #1326 from NetCDF-World-Domination-Council/ejh_file_name_in_built_files
provide NDEBUG version of macro NC_CHECK which does not use code file name
2019-03-08 13:54:53 -07:00
Dennis Heimbigner
98caf87116 Fix ncgen handling of octal constants (with leading 0).
re: https://github.com/Unidata/netcdf-c/issues/1330

The ncgen utility is documented to accept octal integer constants
if the leading digit is zero. This was not implemented. Fix ncgen.l
to properly handle such constants. Also add a test to c0.cdl.
2019-02-25 20:57:23 -07:00
Ed Hartnett
8904c5cbc3 provide NDEBUG version of macro NC_CHECK which does not use code file name 2019-02-16 10:17:06 -07:00
Ward Fisher
e32e0b1eb2
Merge branch 'master' into filterexpr.dmh 2019-02-12 09:48:03 -07:00
Dennis Heimbigner
a6b04c0c66 Extend nccopy -F option syntax.
A user suggested that the nccopy -F option
syntax should be extended to support specification
of multiple (or all) variables in a single -F option.

The new syntax allows:

1. '*' as the name of the variable; this means apply the
   filter to all variables in the data set.
2. *var1|var2|...* as the variable name to indicate that the filter
   should be applied to the multiple specified variables.
2019-02-08 18:48:17 -07:00
Dennis Heimbigner
8714066b18 Fix errors when building on big-endian machine
re: issue https://github.com/Unidata/netcdf-c/issues/1278
re: issue https://github.com/Unidata/netcdf-c/issues/876
re: issue https://github.com/Unidata/netcdf-c/issues/806

* Major change to the handling of 8-byte parameters for nc_def_var_filter.
  The old code was not well thought out.
  * The new algorithm is documented in docs/filters.md.
  * Added new utility file plugins/H5Zutil.c to support
  * Modified plugins/H5Zmisc.c to use new algorithm
  the new algorithm.
  * Renamed include/ncfilter.h to include/netcdf_filter.h
    and made it an installed header so clients can access the
    new algorithm utility.
  * Fixed nc_test4/tst_filterparser.c and nc_test4/test_filter_misc.c
    to use the new algorithm
* libdap4/ fixes:
  * d4swap.c has an error in the endian pre-processing such
    that record counts were not being swapped correctly.
  * d4data.c had an error in that checksums were being computed
    after endian swapping rather than before.
* ocinitialize() was never being called, so xxdr bigendian handling
  was never set correctly.
  * Required adding debug statements to occompile
* Found and fixed memory leak in ncdump.c

Not tested:
* HDF4
* Pnetcdf
* parallel HDF5
2019-01-31 21:13:06 -07:00
Ward Fisher
237f0c6e65 Merge branch 'ejh_tidy' of https://github.com/NetCDF-World-Domination-Council/netcdf-c into pr-aggregation.wif 2019-01-23 15:11:59 -07:00
Ed Hartnett
69d0ac17d9 fixed parallel build issue in ncdump tests 2019-01-20 10:02:31 -07:00
Ward Fisher
9aa003e4c2 Added newline after ncdump -k in support of https://github.com/Unidata/netcdf-c/issues/1246 2019-01-18 15:10:09 -07:00
Dennis Heimbigner
735ae80928 merge master and fix conflicts 2018-12-12 11:47:54 -07:00
Ward Fisher
30ea33435c Merge remote-tracking branch 'origin/license_update.wif' into pr-aggregation.wif 2018-12-11 17:08:21 -05:00
Ward Fisher
02937d2d0e ncdump, other directories updated with copyright stanza. 2018-12-06 15:36:53 -07:00
Dennis Heimbigner
1a7531392f Make the netcdf-c library compile with gcc -ansi.
Primary fixes to get -ansi to work.
1. Convert all '//' C++ style comments to /*...*/ or to use #if 0...#endif
2. It turns out that when -ansi is specified, then a number of
   functions no longer are defined in the header -- but they are still
   in the .so file.<br>
   The big example is strdup(). So, added code to include/ncconfig.h to define
   externs for those missing functions that occur in more than one place.
   These are enabled if !_WIN32 && __STDC__ == 1 (__STDC__ is supposed to
   be the equivalent compile time flag to -ansi). Note that this requires
   config.h (which references ncconfig.h) to be included in files where it is
   currently not included. Single uses will be only in the file that uses them.
3. Added mmap test for the MAP_ANONYMOUS flag to configure.ac. Apparently
   this is not always defined with -ansi.
4. fix some large integer constants in nc_test4/tst_atts3.c and nc_test4/tst_filterparser.c
   to avoid compiler complaints.
5. fix a double constant in nc_test4/tst_filterparser.c to avoid compiler complaints.

[Note I suspect #4 and #5 will be a problem on big-endian machines, but we have no way to test]

Misc. Changes:
1. convert more instances of _MSC_VER to _WIN32.
2. added some debugging code to include/nctestserver.h
3. added comment about libdispatch/drc.c always being compiled.
4. modify parser generation in ncgen to remove unneeded files.
2018-12-05 19:20:43 -07:00
Ed Hartnett
bbfbd98f6e test and util changes to split libsrc4 and libhdf5 2018-12-01 08:24:56 -07:00
Ward Fisher
a068892ace Merge branch 'master' into gh803.wif 2018-11-27 16:09:35 -07:00
Ward Fisher
a8673c3dfe Moving provenance info out so that it doesn't depend on netCDF4 support to display. 2018-11-27 16:09:17 -07:00
Ward Fisher
c1dfe92dab TEMPORARILY turned on printing out hidden attributes for classic and 64-bit offset files while I figure out why they were turned off in the first place. 2018-11-26 18:14:24 -07:00
Ward Fisher
4144f03a44 Added a stanza to not copy _NCProperties atttribute from an old file to a new file, and instead use the properties appropriate for the newly created file. 2018-11-26 17:56:44 -07:00
Ed Hartnett
fe62f61509 fixed makefile typo 2018-11-18 14:59:05 -07:00
Ed Hartnett
6c9ccd97d8 move cleanup to makefile 2018-11-18 13:43:49 -07:00
Ed Hartnett
9796831e70 change rm in test script to use specific file names so parallel builds continue to work 2018-11-18 09:41:21 -07:00
Ward Fisher
53dc9022be Merge remote-tracking branch 'origin/ncgenmem.dmh' into tmptmp 2018-11-15 10:20:08 -07:00
Dennis Heimbigner
751300ec59 Fix more memory leaks in netcdf-c library
This is a follow up to PR https://github.com/Unidata/netcdf-c/pull/1173

Sorry that it is so big, but leak suppression can be complex.

This PR fixes all remaining memory leaks -- as determined by
-fsanitize=address, and with the exceptions noted below.

Unfortunately. there remains a significant leak that I cannot
solve. It involves vlens, and it is unclear if the leak is
occurring in the netcdf-c library or the HDF5 library.

I have added a check_PROGRAM to the ncdump directory to show the
problem.  The program is called tst_vlen_demo.c To exercise it,
build the netcdf library with -fsanitize=address enabled. Then
go into ncdump and do a "make clean check".  This should build
tst_vlen_demo without actually executing it.  Then do the
command "./tst_vlen_demo" to see the output of the memory
checker.  Note the the lost malloc is deep in the HDF5 library
(in H5Tvlen.c).

I am temporarily working around this error in the following way.
1. I modified several test scripts to not execute known vlen tests
   that fail as described above.
2. Added an environment variable called NC_VLEN_NOTEST.
   If set, then those specific tests are suppressed.

This should mean that the --disable-utilities option to
./configure should not need to be set to get a memory leak clean
build.  This should allow for detection of any new leaks.

Note: I used an environment variable rather than a ./configure
option to control the vlen tests. This is because it is
temporary (I hope) and because it is a bit tricky for shell
scripts to access ./configure options.

Finally, as before, this only been tested with netcdf-4 and hdf5 support.
2018-11-15 10:00:38 -07:00
Greg Sjaardema
cd011cd1bb Eliminate compiler warnings (and code error) 2018-11-14 11:00:47 -07:00
Dennis Heimbigner
3ad02fe94f Fix failure in the nccopy -c option
re: https://github.com/Unidata/netcdf-c/issues/1183

Changes:
1. fix typo in nccopy.1 man page
2. fix chunkspec parsing for -c so that "-c var:"
   (with no chunkspec arguments) disables chunking
   on the specified variable
3. Add test case to ncdump/tst_nccopy5.sh
2018-11-12 12:59:56 -07:00
Dennis Heimbigner
245961de00 re: github issues
https://github.com/Unidata/netcdf-c/issues/1168
    https://github.com/Unidata/netcdf-c/issues/1163
    https://github.com/Unidata/netcdf-c/issues/1162

This PR partially fixes memory leaks in the netcdf-c library,
in the ncdump utility, and in some test cases.

The netcdf-c library now runs memory clean with the assumption
that the --disable-utilities option is used. The primary remaining
problem is ncgen. Once that is fixed, I believe the netcdf-c library
will run memory clean with no limitations.

Notes
-----------
1. Memory checking was performed using gcc -fsanitize=address.
   Valgrind-based testing has yet to be performed.
2. The pnetcdf, hdf4, and examples code has not been tested.

Misc. Non-leak changes
1. Make tst_diskless2 only run when netcdf4 is enabled (issue 1162)
2. Fix CmakeLists.txt to turn off logging if ENABLE_NETCDF_4 is OFF
3. Isolated all my debug scripts into a single top-level directory
   called debug
4. Fix some USE_NETCDF4 dependencies in nc_test and nc_test4 Makefile.am
2018-10-30 20:48:12 -06:00
Dennis Heimbigner
7e2a9a9bdf Restore the lost documentation in nccopy.1 of
the new per-variable chunking specifications.
2018-10-13 16:24:37 -06:00
Dennis Heimbigner
4636584d5b Revert/Improve nc_create + NC_DISKLESS behavior
re: https://github.com/Unidata/netcdf-c/issues/1154

Inadvertently, the behavior of NC_DISKLESS with nc_create() was
changed in release 4.6.1. Previously, the NC_WRITE flag needed
to be explicitly used with NC_DISKLESS in order to cause the
created file to be persisted to disk.

Additional analyis indicated that the current NC_DISKLESS
implementation was seriously flawed.

This PR attempts to clean up and regularize the situation with
respect to NC_DISKLESS control. One important aspect of diskless
operation is that there are two different notions of write.

1. The file is read-write vs read-only when using the netcdf API.
2. The file is persisted or not to disk at nc_close().

Previously, these two were conflated. The rules now are
as follows.

1. NC_DISKLESS + NC_WRITE means that the file is read/write using the netcdf API
2. NC_DISKLESS + NC_PERSIST means that the file is persisted to a disk file at nc_close.
3. NC_DISKLESS + NC_PERSIST + NC_WRITE means both 1 and 2.

The NC_PERSIST flag is new and takes over the obsolete NC_MPIPOSIX flag.
NC_MPIPOSIX is still defined, but is now an alias for the NC_MPIIO flag.

It is also now the case that for netcdf-4, NC_DISKLESS is independent
of NC_INMEMORY and in fact it is an error to specify both flags
simultaneously.

Finally, the MMAP code was fixed to use NC_PERSIST as well.
Also marked MMAP as deprecated.

Also added a test case to test various combinations of NC_DISKLESS,
NC_PERSIST, and NC_WRITE.

This PR affects a number of files and especially test cases
that used NC_DISKLESS.

Misc. Unrelated fixes
1. fixed some warnings in ncdump/dumplib.c
2018-10-10 13:32:17 -06:00
Dennis Heimbigner
8072d1f6bb Modify DAP2 and DAP4 to optionally allow Fillvalue/Variable mismatch
re: issue https://github.com/Unidata/netcdf-c/issues/1151

Modify DAP2 and DAP4 code to handle case when _FillValue type is not
same as the parent variable type.

Specifically:
1. Define a parameter [fillmismatch] to allow this mismatch;
   default is to disallow.
2. If allowed, forcibly change the type of the _FillValue to match
   the parent variable.
3. If allowed Convert the values to match new type
4. Generate a log message
5. if not allowed, then fail

Implementing this required some changes to ncdap_test/dapcvt.c
Also added test cases.

Minor Unrelated Changes:
1. There were a number of warnings about e.g.
   assigning a const char* to a char*. Fix these
2. In nccopy.1, replace .NP with .IP "n"
   (re PR https://github.com/Unidata/netcdf-c/pull/1144)
3. fix minor error in ncdump/ocprint
2018-10-01 15:51:43 -06:00
Ward Fisher
6efa25e7e4 Updated and removed a check for _NCProperties during file comparison, as this test fails if the environment is different from the environment the reference file was built on. 2018-09-06 15:53:25 -06:00
Ward Fisher
784d777bff Merge branch 'master' into provenance.dmh 2018-09-06 15:13:09 -06:00
Ward Fisher
3c3119bed2 Merge remote-tracking branch 'origin/dapcurlopt.dmh' into combined-pr.wif 2018-09-04 12:50:55 -06:00
Ward Fisher
ede7c5da60
Merge branch 'master' into provenance.dmh 2018-09-04 11:22:36 -06:00
Dennis Heimbigner
79e38de840 Add the ability to set some additional curlopt values
Add the ability to set some additional curlopt values via .daprc (aka .dodsrc).
This effects both DAP2 and DAP4 protocols.

Related issues:
[1] re: esupport: KOZ-821332
[2] re: github issue https://github.com/Unidata/netcdf4-python/issues/836
[3] re: github issue https://github.com/Unidata/netcdf-c/issues/1074

1. CURLOPT_BUFFERSIZE: Relevant to [1]. Allow user to set the read/write
buffersizes used by curl.
This is done by adding the following to .daprc (aka .dodsrc):
	HTTP.READ.BUFFERSIZE=n
where n is the buffersize in bytes. There is a built-in (to curl)
limit of 512k for this value.

2. CURLOPT_TCP_KEEPALIVE (and CURLOPT_TCP_KEEPIDLE and CURLOPT_TCP_KEEPINTVL):
Relevant (maybe) to [2] and [3]. Allow the user to turn on KEEPALIVE
This is done by adding the following to .daprc (aka .dodsrc):
	HTTP.KEEPALIVE=on|n/m
If the value is "on", then simply enable default KEEPALIVE. If the value
is n/m, then enable KEEPALIVE and set KEEPIDLE to n and KEEPINTVL to m.
2018-08-26 17:04:46 -06:00
Dennis Heimbigner
2ea1cf5f1b There was a request to extend the provenance information
stored in the _NCProperties attribute to allow two things:
1. capture of additional library dependencies (over and above
   hdf5)
2. Recognition of non-netcdf libraries that create netcdf-4 format
   files.

To this end, the _NCProperties format has been extended to be
and arbitrary set of key=value pairs separated by commas.
This new format has version = 2, and uses commas as the pair separator.
Thus the general form is:
    _NCProperties = "version=2,key1=value,key2=value2..." ;

This new version is accompanied by a new ./configure option of the form
    --with-ncproperties="key1=value1,key2=value2..."
that specifies pairs to add to the _NCProperties attribute for all
files created with that netcdf library.

At this point, what is missing is some programmatic way to
specify either all the pairs or additional pairs
to the _NCProperties attribute. Not sure of the best way
to do this.

Builders using non-netcdf libraries can specify
whatever they want in the key value pairs (as long
as the version=2 is specified first).

By convention, the primary library is expected to be the
the first pair after the leading version=2 pair, but this
is convention only and is neither required nor enforced.

Related changes:
1. Fixed the tests that check _NCProperties to properly operate with version=2.
2. When reading a version 1 _NCProperties attribute, convert it to look
   like a version 2 attribute.
2. Added some version 2 tests to ncdump/tst_fileinfo.c and
   ncdump/tst_fileinfo.sh

Misc Changes:
1. Fix minor problem in ncdap_test/testurl.sh where a parameter to
   buildurl needed to be quoted.
2. Minor fix to ncgen to swap switches -H and -h to be consistent
   with other utilities.
3. Document the -M flag in nccopy usage() and the nccopy man page.
4. Modify a test case to use the nccopy -M flag.
2018-08-25 21:44:41 -06:00
Greg Sjaardema
8743de7f34
Eliminate double printing of nccopy program name in usage output
The `error` macro used to output the usage information already outputs `progname`, so the `progname` argument is not needed and results in double printing of the `progname` as shown below:

```
ceerws2703a:build(master)> ../bin/nccopy
../bin/nccopy: ../bin/nccopy [-k kind] [-[3|4|6|7]] [-d n] [-s] [-c chunkspec] [-u] [-w] [-[v|V] varlist] [-[g|G] grplist] [-m n] [-h n] [-e n] [-r] infile outfile
  [-k kind] specify kind of netCDF format for output file, default same as input
            kind strings: 'classic', '64-bit offset', 'cdf5',
                          'netCDF-4', 'netCDF-4 classic model'
```
2018-08-20 11:28:55 -06:00
Ward Fisher
40a929575c sh compatibility. 2018-08-13 00:01:53 -06:00
Ward Fisher
77c3fd023e Removed 'function' keyword for sh compatibility. 2018-08-12 23:23:59 -06:00
Ward Fisher
a996ed554e Swapped /bin/bash for /bin/sh to test on osx. 2018-08-12 23:01:08 -06:00
Dennis Heimbigner
f46b65c602 Clear up coverity complaints
with respect to this coverity report.

https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRZApv53Ry-2FReUME-2Fmei1et81WqdBwm5AxSAYBM9iFSmbw-3D-3D_YxTn3nq1kZ9CfXcyYFaB2DtJSVHTn8U-2BK0LV-2FDyLYKcFvnwYJ7pm2zFB5UovsEUh5miIfeCfQzYxpN9HYcdqs9sKVjtklOkfPIjEpg0Tj8G9wiptznJeX-2FO4PrqJA1ViQYtQfpjugq01XGMQ3-2Bll42dUMxrmbdYSqi8T7bCcANC5evyZs4MKvmAWXt1bnPaHcOYJDN-2FUt-2FJTlhwu91HyR7h-2FnkvMY9paYUNB1gxiyUA-3D
2018-08-04 13:22:29 -06:00
Ward Fisher
81c91eb519 Made some changes to export symbols on Windows builds. 2018-08-02 14:58:47 -06:00
Ward Fisher
f1eb7c77a4 Correcting an appveyor failure. 2018-08-02 11:33:21 -06:00
Ward Fisher
504867ab67 Corrected issue with strings.h. 2018-08-02 09:47:36 -06:00