mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-19 17:30:27 +08:00
Merge remote-tracking branch 'upstream/main' into explicit-casts-in-nc4var
This commit is contained in:
commit
e9f2c18120
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,6 +35,7 @@ test-driver
|
||||
#####
|
||||
|
||||
### 'Normal' gitignore files.
|
||||
docs/auth.html
|
||||
.vscode
|
||||
nug.tag
|
||||
netcdf-c.tag
|
||||
|
@ -1160,7 +1160,8 @@ set_std_filter(Szip)
|
||||
SET(HAVE_SZ ${Szip_FOUND})
|
||||
set_std_filter(Blosc)
|
||||
IF(Zstd_FOUND)
|
||||
set_std_filter(Zstd)
|
||||
set_std_filter(Zstd)
|
||||
SET(HAVE_ZSTD ON)
|
||||
ENDIF()
|
||||
IF(Bz2_FOUND)
|
||||
set_std_filter(Bz2)
|
||||
@ -1168,7 +1169,7 @@ ELSE()
|
||||
# The reason we use a local version is to support a more comples test case
|
||||
MESSAGE("libbz2 not found using built-in version")
|
||||
SET(HAVE_LOCAL_BZ2 ON)
|
||||
SET(HAVE_BZ2 ON)
|
||||
SET(HAVE_BZ2 ON CACHE BOOL "")
|
||||
set(STD_FILTERS "${STD_FILTERS} bz2")
|
||||
ENDIF()
|
||||
|
||||
@ -1507,6 +1508,7 @@ ENDIF()
|
||||
|
||||
# Enable Parallel IO with netCDF-4/HDF5 files using HDF5 parallel I/O.
|
||||
SET(STATUS_PARALLEL "OFF")
|
||||
set(IMPORT_MPI "")
|
||||
OPTION(ENABLE_PARALLEL4 "Build netCDF-4 with parallel IO" "${HDF5_PARALLEL}")
|
||||
IF(ENABLE_PARALLEL4 AND ENABLE_HDF5)
|
||||
IF(NOT HDF5_PARALLEL)
|
||||
@ -1528,6 +1530,7 @@ IF(ENABLE_PARALLEL4 AND ENABLE_HDF5)
|
||||
FILE(COPY "${netCDF_BINARY_DIR}/tmp/run_par_tests.sh"
|
||||
DESTINATION ${netCDF_BINARY_DIR}/h5_test
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
set(IMPORT_MPI "include(CMakeFindDependencyMacro)\nfind_dependency(MPI COMPONENTS C)")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
@ -7,6 +7,7 @@ This file contains a high-level description of this package's evolution. Release
|
||||
|
||||
## 4.9.3 - TBD
|
||||
|
||||
* Obviate a number of irrelevant warnings. See [Github #2781](https://github.com/Unidata/netcdf-c/pull/2781).
|
||||
* Improve the speed and data quantity for DAP4 queries. See [Github #2765](https://github.com/Unidata/netcdf-c/pull/2765).
|
||||
* Remove the use of execinfo to programmatically dump the stack; it never worked. See [Github #2789](https://github.com/Unidata/netcdf-c/pull/2789).
|
||||
* Update the internal copy of tinyxml2 to latest code. See [Github #2771](https://github.com/Unidata/netcdf-c/pull/2771).
|
||||
|
0
cmake/modules/FindBlosc.cmake
Executable file → Normal file
0
cmake/modules/FindBlosc.cmake
Executable file → Normal file
@ -2,7 +2,10 @@
|
||||
#
|
||||
# Szip_FOUND Set to true to indicate the szip library was found
|
||||
# Szip_INCLUDE_DIRS The directory containing the header file szip/szip.h
|
||||
# Szip_LIBRARIES The libraries needed to use the szip library
|
||||
# Szip_LIBRARIES The libraries needed to use the szip library with the word "debug" and "optimized" when both are found
|
||||
# Szip_RELEASE_LIBRARY The path to the Szip release library if available
|
||||
# Szip_DEBUG_LIBRARY The path to the Szip debug library if available
|
||||
# Szip_LIBRARY The path to a Szip library, preferentially release but fallback to debug
|
||||
#
|
||||
# To specify an additional directory to search, set Szip_ROOT.
|
||||
#
|
||||
@ -38,13 +41,17 @@ IF(Szip_INCLUDE_DIRS)
|
||||
PATH_SUFFIXES Release ${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_ARCHITECTURE}/Release
|
||||
PATHS ${Szip_LIBRARY_DIRS} NO_DEFAULT_PATH)
|
||||
|
||||
SET(Szip_LIBRARIES )
|
||||
SET(Szip_LIBRARIES)
|
||||
SET(Szip_LIBRARY)
|
||||
IF(Szip_DEBUG_LIBRARY AND Szip_RELEASE_LIBRARY)
|
||||
SET(Szip_LIBRARIES debug ${Szip_DEBUG_LIBRARY} optimized ${Szip_RELEASE_LIBRARY})
|
||||
SET(Szip_LIBRARY ${Szip_RELEASE_LIBRARY})
|
||||
ELSEIF(Szip_DEBUG_LIBRARY)
|
||||
SET(Szip_LIBRARIES ${Szip_DEBUG_LIBRARY})
|
||||
SET(Szip_LIBRARY ${Szip_DEBUG_LIBRARY})
|
||||
ELSEIF(Szip_RELEASE_LIBRARY)
|
||||
SET(Szip_LIBRARIES ${Szip_RELEASE_LIBRARY})
|
||||
SET(Szip_LIBRARY ${Szip_RELEASE_LIBRARY})
|
||||
ENDIF(Szip_DEBUG_LIBRARY AND Szip_RELEASE_LIBRARY)
|
||||
|
||||
IF(Szip_LIBRARIES)
|
||||
|
0
cmake/modules/FindZip.cmake
Executable file → Normal file
0
cmake/modules/FindZip.cmake
Executable file → Normal file
@ -118,6 +118,12 @@ are set when opening a binary file on Windows. */
|
||||
/* if true, build byte-range Client */
|
||||
#cmakedefine ENABLE_BYTERANGE 1
|
||||
|
||||
/* if true, enable ERANGE fill */
|
||||
#cmakedefine ENABLE_ERANGE_FILL 1
|
||||
#ifdef ENABLE_ERANGE_FILL
|
||||
#define ERANGE_FILL 1
|
||||
#endif
|
||||
|
||||
/* if true, use hdf5 S3 virtual file reader */
|
||||
#cmakedefine ENABLE_HDF5_ROS3 1
|
||||
|
||||
|
@ -1269,15 +1269,6 @@ HTML_COLORSTYLE_SAT = 100
|
||||
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
|
||||
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
|
||||
# page will contain the date and time when the page was generated. Setting this
|
||||
# to YES can help to show when doxygen was last run and thus if the
|
||||
# documentation is up to date.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_TIMESTAMP = NO
|
||||
|
||||
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||
# documentation will contain a main index with vertical navigation menus that
|
||||
# are dynamically created via JavaScript. If disabled, the navigation index will
|
||||
@ -1865,14 +1856,6 @@ LATEX_HIDE_INDICES = NO
|
||||
|
||||
LATEX_BIB_STYLE = plain
|
||||
|
||||
# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
|
||||
# page will contain the date and time when the page was generated. Setting this
|
||||
# to NO can help when comparing the output of multiple runs.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_TIMESTAMP = NO
|
||||
|
||||
# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# path from which the emoji images will be read. If a relative path is entered,
|
||||
# it will be relative to the LATEX_OUTPUT directory. If left blank the
|
||||
|
@ -67,9 +67,9 @@ https://thredds-test.unidata.ucar.edu/thredds/fileServer/irma/metar/files/METAR_
|
||||
|
||||
# References {#nccloud_bib}
|
||||
|
||||
<a name="ref_aws">[1]</a> [Amazon Simple Storage Service Documentation](https://docs.aws.amazon.com/s3/index.html)<br>
|
||||
<a name="ref_awssdk">[2]</a> [Amazon Simple Storage Service Library](https://github.com/aws/aws-sdk-cpp)<br>
|
||||
<a name="ref_awssdk_conda">[11]</a> [Conda-forge / packages / aws-sdk-cpp](https://anaconda.org/conda-forge/aws-sdk-cpp)<br>
|
||||
<a name="cloud_ref_aws">[1]</a> [Amazon Simple Storage Service Documentation](https://docs.aws.amazon.com/s3/index.html)<br>
|
||||
<a name="cloud_ref_awssdk">[2]</a> [Amazon Simple Storage Service Library](https://github.com/aws/aws-sdk-cpp)<br>
|
||||
<a name="cloud_ref_awssdk_conda">[11]</a> [Conda-forge / packages / aws-sdk-cpp](https://anaconda.org/conda-forge/aws-sdk-cpp)<br>
|
||||
|
||||
# Appendix A. S3 Build Support {#nccloud_s3build}
|
||||
|
||||
|
@ -520,7 +520,7 @@ Modifying the dispatch version requires two steps:
|
||||
|
||||
The two should agree in value.
|
||||
|
||||
### NC_DISPATCH_VERSION Incompatibility
|
||||
## NC_DISPATCH_VERSION Incompatibility
|
||||
|
||||
When dynamically adding a dispatch table
|
||||
-- in nc_def_user_format (see libdispatch/dfile.c) --
|
||||
|
118
docs/filters.md
118
docs/filters.md
@ -65,6 +65,28 @@ The concept of a variable-sized type is defined as follows:
|
||||
then that compound type is variable-sized.
|
||||
4. All other types are fixed-size.
|
||||
|
||||
## A Warning on Backward Compatibility {#filters_compatibility}
|
||||
|
||||
The API defined in this document should accurately reflect the
|
||||
current state of filters in the netCDF-c library. Be aware that
|
||||
there was a short period in which the filter code was undergoing
|
||||
some revision and extension. Those extensions have largely been
|
||||
reverted. Unfortunately, some users may experience some
|
||||
compilation problems for previously working code because of
|
||||
these reversions. In that case, please revise your code to
|
||||
adhere to this document. Apologies are extended for any
|
||||
inconvenience.
|
||||
|
||||
A user may encounter an incompatibility if any of the following appears in user code.
|
||||
|
||||
* The function *\_nc\_inq\_var\_filter* was returning the error value NC\_ENOFILTER if a variable had no associated filters.
|
||||
It has been reverted to the previous case where it returns NC\_NOERR and the returned filter id was set to zero if the variable had no filters.
|
||||
* The function *nc\_inq\_var\_filterids* was renamed to *nc\_inq\_var\_filter\_ids*.
|
||||
* Some auxilliary functions for parsing textual filter specifications have been moved to the file *netcdf\_aux.h*. See [Appendix A](#filters_appendixa).
|
||||
* All of the "filterx" functions have been removed. This is unlikely to cause problems because they had limited visibility.
|
||||
|
||||
For additional information, see [Appendix B](#filters_appendixb).
|
||||
|
||||
## Enabling A HDF5 Compression Filter {#filters_enable}
|
||||
|
||||
HDF5 supports dynamic loading of compression filters using the
|
||||
@ -611,7 +633,99 @@ As part of its testing, the NetCDF build process creates a number of shared libr
|
||||
If you need a filter from that set, you may be able to set *HDF5\_PLUGIN\_PATH*
|
||||
to point to that directory or you may be able to copy the shared libraries out of that directory to your own location.
|
||||
|
||||
## Debugging {#filters_debug}
|
||||
# Lossy One-Way Filters
|
||||
|
||||
As of NetCDF version 4.8.2, the netcdf-c library supports
|
||||
bit-grooming filters.
|
||||
````
|
||||
Bit-grooming is a lossy compression algorithm that removes the
|
||||
bloat due to false-precision, those bits and bytes beyond the
|
||||
meaningful precision of the data. Bit Grooming is statistically
|
||||
unbiased, applies to all floating point numbers, and is easy to
|
||||
use. Bit-Grooming reduces data storage requirements by
|
||||
25-80%. Unlike its best-known competitor Linear Packing, Bit
|
||||
Grooming imposes no software overhead on users, and guarantees
|
||||
its precision throughout the whole floating point range
|
||||
[https://doi.org/10.5194/gmd-9-3199-2016].
|
||||
````
|
||||
The generic term "quantize" is used to refer collectively to the various
|
||||
precision-trimming algorithms. The key thing to note about quantization is that
|
||||
it occurs at the point of writing of data only. Since its output is
|
||||
legal data, it does not need to be "de-quantized" when the data is read.
|
||||
Because of this, quantization is not part of the standard filter
|
||||
mechanism and has a separate API.
|
||||
|
||||
The API for bit-groom is currently as follows.
|
||||
````
|
||||
int nc_def_var_quantize(int ncid, int varid, int quantize_mode, int nsd);
|
||||
int nc_inq_var_quantize(int ncid, int varid, int *quantize_modep, int *nsdp);
|
||||
````
|
||||
The *quantize_mode* argument specifies the particular algorithm.
|
||||
Currently, three are supported: NC_QUANTIZE_BITGROOM, NC_QUANTIZE_GRANULARBR,
|
||||
and NC_QUANTIZE_BITROUND. In addition quantization can be disabled using
|
||||
the value NC_NOQUANTIZE.
|
||||
|
||||
The input to ncgen or the output from ncdump supports special attributes
|
||||
to indicate if quantization was applied to a given variable.
|
||||
These attributes have the following form.
|
||||
````
|
||||
_QuantizeBitGroomNumberOfSignificantDigits = <NSD>
|
||||
or
|
||||
_QuantizeGranularBitRoundNumberOfSignificantDigits = <NSD>
|
||||
or
|
||||
_QuantizeBitRoundNumberOfSignificantBits = <NSB>
|
||||
````
|
||||
The value NSD is the number of significant (decimal) digits to keep.
|
||||
The value NSB is the number of bits to keep in the fraction part of an
|
||||
IEEE754 floating-point number. Note that NSB of QuantizeBitRound is the same as
|
||||
"number of explicit mantissa bits" (https://doi.org/10.5194/gmd-9-3199-2016) and same as
|
||||
the number of "keep-bits" (https://doi.org/10.5194/gmd-14-377-2021), but is not
|
||||
one less than the number of significant bunary figures:
|
||||
`_QuantizeBitRoundNumberOfSignificantBits = 0` means one significant binary figure,
|
||||
`_QuantizeBitRoundNumberOfSignificantBits = 1` means two significant binary figures etc.
|
||||
|
||||
## Distortions introduced by lossy filters
|
||||
|
||||
Any lossy filter introduces distortions to data.
|
||||
The lossy filters implemented in netcdf-c introduce a distortoin
|
||||
that can be quantified in terms of a _relative_ error. The magnitude of
|
||||
distortion introduced to every single value V is guaranteed to be within
|
||||
a certain fraction of V, expressed as 0.5 * V * 2**{-NSB}:
|
||||
i.e. it is 0.5V for NSB=0, 0.25V for NSB=1, 0.125V for NSB=2 etc.
|
||||
|
||||
|
||||
Two other methods use different definitions of _decimal precision_, though both
|
||||
are guaranteed to reproduce NSD decimals when printed.
|
||||
The margin for a relative error introduced by the methods are summarised in the table
|
||||
|
||||
```
|
||||
NSD 1 2 3 4 5 6 7
|
||||
|
||||
BitGroom
|
||||
Error Margin 3.1e-2 3.9e-3 4.9e-4 3.1e-5 3.8e-6 4.7e-7 -
|
||||
|
||||
GranularBitRound
|
||||
Error Margin 1.4e-1 1.9e-2 2.2e-3 1.4e-4 1.8e-5 2.2e-6 -
|
||||
|
||||
```
|
||||
|
||||
|
||||
If one defines decimal precision as in BitGroom, i.e. the introduced relative
|
||||
error must not exceed half of the unit at the decimal place NSD in the
|
||||
worst-case scenario, the following values of NSB should be used for BitRound:
|
||||
|
||||
```
|
||||
NSD 1 2 3 4 5 6 7
|
||||
NSB 3 6 9 13 16 19 23
|
||||
```
|
||||
|
||||
The resulting application of BitRound is as fast as BitGroom, and is free from
|
||||
artifacts in multipoint statistics introduced by BitGroom
|
||||
(see https://doi.org/10.5194/gmd-14-377-2021).
|
||||
|
||||
|
||||
# Debugging {#filters_debug}
|
||||
|
||||
|
||||
Depending on the debugger one uses, debugging plugins can be very difficult.
|
||||
It may be necessary to use the old printf approach for debugging the filter itself.
|
||||
@ -625,7 +739,7 @@ This can be accomplished using this command.
|
||||
Since ncdump is not being asked to access the data (the -h flag), it can obtain the filter information without failures.
|
||||
Then it can print out the filter id and the parameters as well as the Codecs (via the -s flag).
|
||||
|
||||
### Test Cases {#filters_TestCase}
|
||||
## Test Cases {#filters_TestCase}
|
||||
|
||||
Within the netcdf-c source tree, the directory two directories contain test cases for testing dynamic filter operation.
|
||||
|
||||
|
@ -8,13 +8,13 @@ This document attempts to record important information about
|
||||
the internal architecture and operation of the netcdf-c library.
|
||||
It covers the following issues.
|
||||
|
||||
* [Including C++ Code in the netcdf-c Library](#intern_c++)
|
||||
* [Including C++ Code in the netcdf-c Library](#intern_cpp)
|
||||
* [Managing instances of variable-length data types](#intern_vlens)
|
||||
* [Inferring File Types](#intern_infer)
|
||||
* [Adding a Standard Filter](#intern_filters)
|
||||
* [Test Interference](#intern_isolation)
|
||||
|
||||
# 1. Including C++ Code in the netcdf-c Library {#intern_c++}
|
||||
# 1. Including C++ Code in the netcdf-c Library {#intern_cpp}
|
||||
|
||||
The state of C compiler technology has reached the point where
|
||||
it is possible to include C++ code into the netcdf-c library
|
||||
|
@ -13,7 +13,7 @@ The NetCDF homepage may be found at <a href="https://www.unidata.ucar.edu/softwa
|
||||
|
||||
You can find the documentation for netCDF-Fortran here:
|
||||
|
||||
- <a href="https://www.unidata.ucar.edu/software/netcdf/fortran/docs"> The NetCDF-Fortran Developer's Guide</a>
|
||||
- <a href="https://docs.unidata.ucar.edu/netcdf-fortran/current/"> The NetCDF-Fortran Developer's Guide</a>
|
||||
|
||||
\section this_release Learn more about the current NetCDF-C Release
|
||||
|
||||
|
@ -417,7 +417,7 @@ In order to accomodate existing implementations, certain mode tags are provided
|
||||
|
||||
## XArray
|
||||
|
||||
The Xarray <a href="#ref_xarray">[7]</a> Zarr implementation uses its own mechanism for specifying shared dimensions.
|
||||
The Xarray [XArray Zarr Encoding Specification](http://xarray.pydata.org/en/latest/internals.html#zarr-encoding-specification) Zarr implementation uses its own mechanism for specifying shared dimensions.
|
||||
It uses a special attribute named ''_ARRAY_DIMENSIONS''.
|
||||
The value of this attribute is a list of dimension names (strings).
|
||||
An example might be ````["time", "lon", "lat"]````.
|
||||
@ -449,16 +449,16 @@ Here are a couple of examples using the _ncgen_ and _ncdump_ utilities.
|
||||
```
|
||||
4. Create an nczarr file using S3 as storage and keeping to the pure zarr format.
|
||||
```
|
||||
ncgen -4 -lb -o "s3://s3.uswest-1.amazonaws.com/datasetbucket#mode=zarr" dataset.cdl
|
||||
ncgen -4 -lb -o 's3://s3.uswest-1.amazonaws.com/datasetbucket\#mode=zarr dataset.cdl
|
||||
```
|
||||
5. Create an nczarr file using the s3 protocol with a specific profile
|
||||
```
|
||||
ncgen -4 -lb -o "s3://datasetbucket/rootkey#mode=nczarr,awsprofile=unidata" dataset.cdl
|
||||
ncgen -4 -lb -o 's3://datasetbucket/rootkey\#mode=nczarr,awsprofile=unidata' dataset.cdl
|
||||
```
|
||||
Note that the URL is internally translated to this
|
||||
````
|
||||
https://s2.<region>.amazonaws.com/datasetbucket/rootkey#mode=nczarr,awsprofile=unidata" dataset.cdl
|
||||
````
|
||||
```
|
||||
'https://s2.<region>.amazonaws.com/datasetbucket/rootkey#mode=nczarr,awsprofile=unidata' dataset.cdl
|
||||
```
|
||||
|
||||
# References {#nczarr_bib}
|
||||
|
||||
@ -473,7 +473,7 @@ collections — High-performance dataset datatypes](https://docs.python.org/2/li
|
||||
<a name="dynamic_filter_loading">[8]</a> [Dynamic Filter Loading](https://support.hdfgroup.org/HDF5/doc/Advanced/DynamicallyLoadedFilters/HDF5DynamicallyLoadedFilters.pdf)<br>
|
||||
<a name="official_hdf5_filters">[9]</a> [Officially Registered Custom HDF5 Filters](https://portal.hdfgroup.org/display/support/Registered+Filter+Plugins)<br>
|
||||
<a name="blosc-c-impl">[10]</a> [C-Blosc Compressor Implementation](https://github.com/Blosc/c-blosc)<br>
|
||||
<a name="ref_awssdk_conda">[11]</a> [Conda-forge / packages / aws-sdk-cpp](https://anaconda.org/conda-forge/aws-sdk-cpp)<br>
|
||||
<a name="ref_awssdk_conda">[11]</a> [Conda-forge packages / aws-sdk-cpp](https://anaconda.org/conda-forge/aws-sdk-cpp)<br>
|
||||
<a name="ref_gdal">[12]</a> [GDAL Zarr](https://gdal.org/drivers/raster/zarr.html)<br>
|
||||
|
||||
# Appendix A. Building NCZarr Support {#nczarr_build}
|
||||
@ -539,7 +539,7 @@ PATH="$PATH:${AWSSDKBIN}"
|
||||
Then the following options must be specified for cmake.
|
||||
````
|
||||
-DAWSSDK_ROOT_DIR=${AWSSDK_ROOT_DIR}
|
||||
-DAWSSDK_DIR=${AWSSDK_ROOT_DIR}/lib/cmake/AWSSDK"
|
||||
-DAWSSDK_DIR=${AWSSDK_ROOT_DIR}/lib/cmake/AWSSDK
|
||||
````
|
||||
# Appendix B. Amazon S3 Imposed Limits {#nczarr_s3limits}
|
||||
|
||||
@ -578,7 +578,7 @@ can in fact be any legal JSON expression.
|
||||
This "convention" is currently used routinely to help support various
|
||||
attributes created by other packages where the attribute is a
|
||||
complex JSON expression. An example is the GDAL Driver
|
||||
convention <a href="#ref_gdal">[12]</a>, where the value is a complex
|
||||
convention <a href='#ref_gdal'>[12]</a>, where the value is a complex
|
||||
JSON dictionary.
|
||||
|
||||
In order for NCZarr to be as consistent as possible with Zarr Version 2,
|
||||
|
0
docs/testserver.dox
Executable file → Normal file
0
docs/testserver.dox
Executable file → Normal file
@ -452,7 +452,7 @@ main()
|
||||
hr_data_out[i].starfleet_id = i;
|
||||
hr_data_out[i].svc_rec.i1 = 95;
|
||||
hr_data_out[i].svc_rec.i2 = 90;
|
||||
if (sprintf(hr_data_out[i].name, "alien_%d", i) < 0) ERR;
|
||||
if (snprintf(hr_data_out[i].name, sizeof(hr_data_out[i].name), "alien_%d", i) < 0) ERR;
|
||||
hr_data_out[i].max_temp = 99.99f;
|
||||
hr_data_out[i].min_temp = -9.99f;
|
||||
hr_data_out[i].percent_transporter_errosion = .1;
|
||||
@ -557,7 +557,7 @@ main()
|
||||
hr_data_out[i].starfleet_id = i;
|
||||
hr_data_out[i].svc_rec.i1 = 95;
|
||||
hr_data_out[i].svc_rec.i2 = 90;
|
||||
if (sprintf(hr_data_out[i].name, "alien_%d", i) < 0) ERR;
|
||||
if (snprintf(hr_data_out[i].name, sizeof(hr_data_out[i].name), "alien_%d", i) < 0) ERR;
|
||||
hr_data_out[i].max_temp = 99.99f;
|
||||
hr_data_out[i].min_temp = -9.99f;
|
||||
hr_data_out[i].percent_transporter_errosion = .1;
|
||||
@ -665,7 +665,7 @@ main()
|
||||
hr_data_out[i].starfleet_id = i;
|
||||
hr_data_out[i].svc_rec.i1 = 95;
|
||||
hr_data_out[i].svc_rec.i2 = 90;
|
||||
if (sprintf(hr_data_out[i].name, "alien_%d", i) < 0) ERR;
|
||||
if (snprintf(hr_data_out[i].name, sizeof(hr_data_out[i].name), "alien_%d", i) < 0) ERR;
|
||||
hr_data_out[i].max_temp = 99.99f;
|
||||
hr_data_out[i].min_temp = -9.99f;
|
||||
hr_data_out[i].percent_transporter_errosion = .1;
|
||||
@ -756,7 +756,7 @@ main()
|
||||
/* Create some phony data. */
|
||||
for (i = 0; i < DIM1_LEN; i++)
|
||||
{
|
||||
if (sprintf(hr_data_out[i].name, "alien_%d", i) < 0) ERR;
|
||||
if (snprintf(hr_data_out[i].name, sizeof(hr_data_out[i].name), "alien_%d", i) < 0) ERR;
|
||||
hr_data_out[i].max_temp = 99.99f;
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ main()
|
||||
/* Create some phony data. */
|
||||
for (i = 0; i < DIM2_LEN; i++)
|
||||
{
|
||||
if (sprintf(hr_data_out[i].name, "alien_%d", i) < 0) ERR;
|
||||
if (snprintf(hr_data_out[i].name, sizeof(hr_data_out[i].name), "alien_%d", i) < 0) ERR;
|
||||
hr_data_out[i].max_temp = 99.99f;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ main()
|
||||
if ((var1_spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
|
||||
for (v = 0; v < NUM_DATASETS; v++)
|
||||
{
|
||||
sprintf(var_name, "var_%d", v);
|
||||
snprintf(var_name, sizeof(var_name), "var_%d", v);
|
||||
if ((var1_datasetid[v] = H5Dcreate1(grpid, var_name, H5T_NATIVE_INT,
|
||||
var1_spaceid, H5P_DEFAULT)) < 0) ERR;
|
||||
if (H5DSattach_scale(var1_datasetid[v], dimscaleid, 0) < 0) ERR;
|
||||
|
@ -633,6 +633,7 @@ main()
|
||||
hsize_t h5dimlen[DIMS2], h5dimlenmax[DIMS2], xtend_size[DIMS2] = {1, NUM_VALS};
|
||||
hsize_t start[DIMS2] = {0, 0};
|
||||
hsize_t count[DIMS2] = {1, NUM_VALS};
|
||||
hsize_t ones[DIMS2] = {1, 1};
|
||||
double value[NUM_VALS];
|
||||
int dataset_ndims;
|
||||
int i;
|
||||
@ -661,7 +662,7 @@ main()
|
||||
|
||||
/* Set up the file and memory spaces. */
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
if ((mem_spaceid = H5Screate_simple(DIMS2, count, NULL)) < 0) ERR;
|
||||
|
||||
/* Write a slice of data. */
|
||||
@ -683,7 +684,7 @@ main()
|
||||
/* Set up the file and memory spaces for a second slice. */
|
||||
start[0]++;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
if ((mem_spaceid = H5Screate_simple(DIMS2, count, NULL)) < 0) ERR;
|
||||
|
||||
/* Write a second slice of data. */
|
||||
|
@ -93,7 +93,7 @@ main()
|
||||
spaceid, create_propid)) < 0) ERR;
|
||||
if (H5Sclose(spaceid) < 0) ERR;
|
||||
if (H5Pclose(create_propid) < 0) ERR;
|
||||
sprintf(dimscale_wo_var, "%s%10d", DIM_WITHOUT_VARIABLE, DIM_LEN);
|
||||
snprintf(dimscale_wo_var, sizeof(dimscale_wo_var), "%s%10d", DIM_WITHOUT_VARIABLE, DIM_LEN);
|
||||
if (H5DSset_scale(dimscaleid, dimscale_wo_var) < 0) ERR;
|
||||
|
||||
/* Create a variable that uses this dimension scale. */
|
||||
|
@ -154,7 +154,7 @@ main()
|
||||
char lang[NUM_LANG][STR_LEN + 1] = {"C", "Fortran", "C++", "MISSING"};
|
||||
enum langs {CLANG=0, Fortran=1, CPP=2, MISSING=255};
|
||||
short the_value, fill_value = MISSING, data_point = CLANG;
|
||||
hsize_t start[1] = {1}, count[1] = {1};
|
||||
hsize_t start[1] = {1}, count[1] = {1}, one[1] = {1};
|
||||
int num_members;
|
||||
size_t size;
|
||||
hid_t base_hdf_typeid;
|
||||
@ -197,7 +197,7 @@ main()
|
||||
if ((mem_spaceid = H5Screate(H5S_SCALAR)) < 0) ERR;
|
||||
if ((file_spaceid = H5Screate_simple(1, dims, NULL)) < 0) ERR;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, one, count) < 0) ERR;
|
||||
if (H5Dwrite(datasetid, typeid, mem_spaceid, file_spaceid,
|
||||
H5P_DEFAULT, &data_point) < 0) ERR;
|
||||
|
||||
|
@ -174,7 +174,7 @@ main()
|
||||
#define MILLION 1000000
|
||||
|
||||
hid_t fileid, write_spaceid, datasetid, mem_spaceid;
|
||||
hsize_t start[NDIMS], count[NDIMS];
|
||||
hsize_t start[NDIMS], count[NDIMS], ones[NDIMS];
|
||||
hsize_t dims[1];
|
||||
int *data;
|
||||
int num_steps;
|
||||
@ -210,8 +210,9 @@ main()
|
||||
{
|
||||
/* Select hyperslab for write of one slice. */
|
||||
start[0] = s * SC;
|
||||
ones[0] = 1;
|
||||
if (H5Sselect_hyperslab(write_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
if (H5Dwrite(datasetid, H5T_NATIVE_INT, mem_spaceid, write_spaceid,
|
||||
H5P_DEFAULT, data) < 0) ERR;
|
||||
@ -242,13 +243,13 @@ main()
|
||||
hid_t mem_spaceid, xfer_plistid, native_typeid;
|
||||
hsize_t *chunksize, dims[1], maxdims[1], *dimsize, *maxdimsize;
|
||||
hsize_t fdims[MAX_DIMS], fmaxdims[MAX_DIMS];
|
||||
hsize_t start[MAX_DIMS], count[MAX_DIMS];
|
||||
hsize_t start[MAX_DIMS], count[MAX_DIMS], ones[MAX_DIMS];
|
||||
char file_name[STR_LEN + 1];
|
||||
char dimscale_wo_var[STR_LEN];
|
||||
void *bufr;
|
||||
void *fillp = NULL;
|
||||
|
||||
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE_NAME);
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", TEMP_LARGE, FILE_NAME);
|
||||
|
||||
/* Create file access and create property lists. */
|
||||
if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
|
||||
@ -285,7 +286,7 @@ main()
|
||||
spaceid, plistid)) < 0) ERR;
|
||||
if (H5Sclose(spaceid) < 0) ERR;
|
||||
if (H5Pclose(plistid) < 0) ERR;
|
||||
sprintf(dimscale_wo_var, "%s%10d", DIM_WITHOUT_VARIABLE, DIM1);
|
||||
snprintf(dimscale_wo_var, sizeof(dimscale_wo_var), "%s%10d", DIM_WITHOUT_VARIABLE, DIM1);
|
||||
if (H5DSset_scale(dim1_dimscaleid, dimscale_wo_var) < 0) ERR;
|
||||
|
||||
/* Create the dim2 dimscale. */
|
||||
@ -299,7 +300,7 @@ main()
|
||||
spaceid, plistid)) < 0) ERR;
|
||||
if (H5Sclose(spaceid) < 0) ERR;
|
||||
if (H5Pclose(plistid) < 0) ERR;
|
||||
sprintf(dimscale_wo_var, "%s%10d", DIM_WITHOUT_VARIABLE, DIM2);
|
||||
snprintf(dimscale_wo_var, sizeof(dimscale_wo_var), "%s%10d", DIM_WITHOUT_VARIABLE, DIM2);
|
||||
if (H5DSset_scale(dim2_dimscaleid, dimscale_wo_var) < 0) ERR;
|
||||
|
||||
/* Now create the 2D dataset. */
|
||||
@ -342,7 +343,8 @@ main()
|
||||
start[1] = 0;
|
||||
count[0] = 1;
|
||||
count[1] = 2097153;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) ERR;
|
||||
ones[0] = ones[1] = 1;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, NULL, ones, count) < 0) ERR;
|
||||
if ((mem_spaceid = H5Screate_simple(NDIMS2, count, NULL)) < 0) ERR;
|
||||
if ((xfer_plistid = H5Pcreate(H5P_DATASET_XFER)) < 0) ERR;
|
||||
if ((native_typeid = H5Tget_native_type(H5T_NATIVE_SCHAR, H5T_DIR_DEFAULT)) < 0) ERR;
|
||||
|
@ -67,7 +67,7 @@ main()
|
||||
/* Create the variables. */
|
||||
for (v = 0; v < NUM_DATASETS; v++)
|
||||
{
|
||||
sprintf(var_name, "var_%d", v);
|
||||
snprintf(var_name, sizeof(var_name), "var_%d", v);
|
||||
/* printf("creating var %s\n", var_name);*/
|
||||
if ((datasetid[v] = H5Dcreate1(grpid, var_name, H5T_NATIVE_INT,
|
||||
spaceid, plistid)) < 0) ERR_RET;
|
||||
|
@ -66,7 +66,7 @@ main(int argc, char **argv)
|
||||
printf("*** Creating file for parallel I/O read, and rereading it...");
|
||||
{
|
||||
hid_t fapl_id, fileid, whole_spaceid, dsid, slice_spaceid, whole_spaceid1, xferid;
|
||||
hsize_t start[NDIMS], count[NDIMS];
|
||||
hsize_t start[NDIMS], count[NDIMS], ones[NDIMS];
|
||||
hsize_t dims[1];
|
||||
int data[SC1], data_in[SC1];
|
||||
int num_steps;
|
||||
@ -126,8 +126,9 @@ main(int argc, char **argv)
|
||||
/* Select hyperslab for write of one slice. */
|
||||
start[0] = s * SC1 * p + my_rank * SC1;
|
||||
count[0] = SC1;
|
||||
ones[0] = 1;
|
||||
if (H5Sselect_hyperslab(whole_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
if (H5Dwrite(dsid, H5T_NATIVE_INT, slice_spaceid, whole_spaceid,
|
||||
xferid, data) < 0) ERR;
|
||||
@ -185,8 +186,9 @@ main(int argc, char **argv)
|
||||
/* Select hyperslab for read of one slice. */
|
||||
start[0] = s * SC1 * p + my_rank * SC1;
|
||||
count[0] = SC1;
|
||||
ones[0] = 1;
|
||||
if (H5Sselect_hyperslab(whole_spaceid1, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0)
|
||||
start, NULL, ones, count) < 0)
|
||||
{
|
||||
ERR;
|
||||
return 2;
|
||||
|
@ -51,7 +51,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
hid_t fapl_id, fileid, whole_spaceid, dsid, slice_spaceid, whole_spaceid1, xferid;
|
||||
hid_t plistid;
|
||||
hsize_t start[NDIMS], count[NDIMS];
|
||||
hsize_t start[NDIMS], count[NDIMS], ones[NDIMS];
|
||||
hsize_t dims[1], chunksize = SC1;
|
||||
int data[SC1], data_in[SC1];
|
||||
int num_steps;
|
||||
@ -120,8 +120,9 @@ main(int argc, char **argv)
|
||||
/* Select hyperslab for write of one slice. */
|
||||
start[0] = s * SC1 * p + my_rank * SC1;
|
||||
count[0] = SC1;
|
||||
ones[0] = 1;
|
||||
if (H5Sselect_hyperslab(whole_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
if (H5Dwrite(dsid, H5T_NATIVE_INT, slice_spaceid, whole_spaceid,
|
||||
xferid, data) < 0) ERR;
|
||||
@ -160,8 +161,9 @@ main(int argc, char **argv)
|
||||
/* Select hyperslab for read of one slice. */
|
||||
start[0] = s * SC1 * p + my_rank * SC1;
|
||||
count[0] = SC1;
|
||||
ones[0] = 1;
|
||||
if (H5Sselect_hyperslab(whole_spaceid1, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0)
|
||||
start, NULL, ones, count) < 0)
|
||||
{
|
||||
ERR;
|
||||
return 2;
|
||||
|
@ -30,6 +30,7 @@ main()
|
||||
hid_t file_spaceid, mem_spaceid;
|
||||
hsize_t dims[1] = {0}, max_dims[1] = {H5S_UNLIMITED}, chunk_dims[1] = {1};
|
||||
hsize_t xtend_size[NDIMS] = {2}, start[NDIMS] = {1}, count[NDIMS] = {1};
|
||||
hsize_t ones[NDIMS] = {1};
|
||||
/* void *fillp;*/
|
||||
char *data = "A man who carries a cat by the tail learns "
|
||||
"something he can learn in no other way.";
|
||||
@ -91,7 +92,7 @@ main()
|
||||
/* Select space in file to write a record. */
|
||||
if ((file_spaceid = H5Dget_space(datasetid)) < 0) ERR;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
/* Select space in memory to read from. */
|
||||
if ((mem_spaceid = H5Screate_simple(NDIMS, count, NULL)) < 0) ERR;
|
||||
@ -126,7 +127,7 @@ main()
|
||||
hid_t typeid, datasetid, plistid;
|
||||
hid_t file_spaceid, mem_spaceid;
|
||||
hsize_t dims[1] = {2}, chunk_dims[1] = {1};
|
||||
hsize_t start[NDIMS] = {1}, count[NDIMS] = {1};
|
||||
hsize_t start[NDIMS] = {1}, count[NDIMS] = {1}, ones[NDIMS] = {1};
|
||||
/* void *fillp;*/
|
||||
char *data = "A man who carries a cat by the tail learns "
|
||||
"something he can learn in no other way.";
|
||||
@ -179,7 +180,7 @@ To be good is noble; but to show others how to be good is nobler and no trouble.
|
||||
/* Select space in file to write a record. */
|
||||
if ((file_spaceid = H5Dget_space(datasetid)) < 0) ERR;
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
/* Select space in memory to read from. */
|
||||
if ((mem_spaceid = H5Screate_simple(NDIMS, count, NULL)) < 0)
|
||||
|
@ -69,7 +69,7 @@ main()
|
||||
float float_data_out[LAT_LEN][LON_LEN];
|
||||
hsize_t dims[NDIMS], max_dims[NDIMS];
|
||||
hsize_t dims_in[NDIMS], max_dims_in[NDIMS];
|
||||
hsize_t start[MAX_DIMS], count[MAX_DIMS];
|
||||
hsize_t start[MAX_DIMS], count[MAX_DIMS], ones[MAX_DIMS];
|
||||
int lat, lon;
|
||||
|
||||
/* Set up some phoney data, 1 record's worth. In C, first
|
||||
@ -153,8 +153,9 @@ main()
|
||||
start[0] = 1;
|
||||
start[1] = 0;
|
||||
start[2] = 0;
|
||||
ones[0] = ones[1] = ones[2] = 1;
|
||||
if (H5Sselect_hyperslab(write_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, count, NULL) < 0) ERR;
|
||||
start, NULL, ones, count) < 0) ERR;
|
||||
|
||||
/* Write second record of data to each dataset. */
|
||||
if (H5Dwrite(pres_dsid, H5T_IEEE_F32LE, mem_spaceid, write_spaceid,
|
||||
@ -517,7 +518,7 @@ main()
|
||||
"szip_and_zlib"};
|
||||
|
||||
/* Open file and create group. */
|
||||
sprintf(file_name, "%s_%s.h5", TEST_NAME, desc[f]);
|
||||
snprintf(file_name, sizeof(file_name), "%s_%s.h5", TEST_NAME, desc[f]);
|
||||
if ((fileid = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT,
|
||||
H5P_DEFAULT)) < 0) ERR;
|
||||
if ((grpid = H5Gcreate1(fileid, GRP_NAME, 0)) < 0) ERR;
|
||||
|
@ -478,7 +478,7 @@ main()
|
||||
/* Create the variables. */
|
||||
for (v = 0; v < NUM_DATASETS; v++)
|
||||
{
|
||||
sprintf(var_name, "var_%d", v);
|
||||
snprintf(var_name, sizeof(var_name), "var_%d", v);
|
||||
/* printf("creating var %s\n", var_name);*/
|
||||
if ((datasetid[v] = H5Dcreate1(grpid, var_name, H5T_NATIVE_INT,
|
||||
spaceid, plistid)) < 0) ERR_RET;
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "h5_err_macros.h"
|
||||
#include <hdf5.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define FILE_NAME "tst_h_vl.h5"
|
||||
#define DIM1_LEN 3
|
||||
@ -23,7 +24,7 @@ main()
|
||||
hsize_t dims[1] = {DIM1_LEN};
|
||||
hvl_t data[DIM1_LEN], data_in[DIM1_LEN];
|
||||
int *phoney;
|
||||
int i, j;
|
||||
size_t i, j;
|
||||
size_t size;
|
||||
|
||||
/* Create some phoney data, an array of struct s1, which holds a
|
||||
|
@ -141,7 +141,7 @@ main(int argc, char **argv)
|
||||
/* Create some HDF4 datasets. */
|
||||
for (t = 0; t < NUM_TYPES; t++)
|
||||
{
|
||||
sprintf(tmp_name, "hdf4_dataset_type_%d", t);
|
||||
snprintf(tmp_name, sizeof(tmp_name), "hdf4_dataset_type_%d", t);
|
||||
if ((sds_id = SDcreate(sd_id, tmp_name, hdf4_type[t],
|
||||
DIMS_3, dim_size)) == FAIL) ERR;
|
||||
/* Set up dimensions. By giving them the same names for each
|
||||
|
@ -131,7 +131,7 @@ typedef struct NC_OBJ
|
||||
{
|
||||
NC_SORT sort; /**< Type of object. */
|
||||
char* name; /**< Name, assumed to be null terminated. */
|
||||
size_t id; /**< This objects ID. */
|
||||
int id; /**< This objects ID. */
|
||||
} NC_OBJ;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,9 @@
|
||||
#ifdef HAVE_DIRENT_H
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
@ -6,6 +6,9 @@
|
||||
#ifndef NCS3SDK_H
|
||||
#define NCS3SDK_H 1
|
||||
|
||||
#define AWSHOST ".amazonaws.com"
|
||||
#define GOOGLEHOST "storage.googleapis.com"
|
||||
|
||||
/* Track the server type, if known */
|
||||
typedef enum NCS3SVC {NCS3UNK=0, /* unknown */
|
||||
NCS3=1, /* s3.amazon.aws */
|
||||
|
@ -52,7 +52,7 @@ parseServers(const char* remotetestservers)
|
||||
|
||||
/* Keep LGTM quiet */
|
||||
if(rtslen > MAXREMOTETESTSERVERS) goto done;
|
||||
list = (char**)malloc(sizeof(char*) * (int)(rtslen/2));
|
||||
list = (char**)malloc(sizeof(char*) * (rtslen/2));
|
||||
if(list == NULL) return NULL;
|
||||
rts = strdup(remotetestservers);
|
||||
if(rts == NULL) goto done;
|
||||
|
@ -150,14 +150,14 @@ typedef struct timeinfo_t {
|
||||
# define MSC_NCTIME_EXTRA __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
MSC_NCTIME_EXTRA extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime);
|
||||
MSC_NCTIME_EXTRA extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime, size_t chartime_size);
|
||||
MSC_NCTIME_EXTRA extern void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
|
||||
MSC_NCTIME_EXTRA extern void Cdh2e(CdTime *htime, double *etime);
|
||||
MSC_NCTIME_EXTRA extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
|
||||
MSC_NCTIME_EXTRA extern int cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTime* base_comptime);
|
||||
MSC_NCTIME_EXTRA extern int cdSetErrOpts(int opts);
|
||||
#else
|
||||
extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime);
|
||||
extern void cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime, size_t chartime_size);
|
||||
extern void cdChar2Comp(cdCalenType timetype, char* chartime, cdCompTime* comptime);
|
||||
extern void Cdh2e(CdTime *htime, double *etime);
|
||||
extern void Cde2h(double etime, CdTimeType timeType, long baseYear, CdTime *htime);
|
||||
|
@ -38,7 +38,7 @@ dumpmetadata(int ncid, NChdr** hdrp)
|
||||
fprintf(stdout,"ncid=%d ngatts=%d ndims=%d nvars=%d unlimid=%d\n",
|
||||
hdr->ncid,hdr->ngatts,hdr->ndims,hdr->nvars,hdr->unlimid);
|
||||
#endif
|
||||
hdr->gatts = (NCattribute*)calloc(1,hdr->ngatts*sizeof(NCattribute));
|
||||
hdr->gatts = (NCattribute*)calloc(1, (size_t)hdr->ngatts*sizeof(NCattribute));
|
||||
MEMCHECK(hdr->gatts,NC_ENOMEM);
|
||||
if(hdr->ngatts > 0)
|
||||
fprintf(stdout,"global attributes:\n");
|
||||
@ -81,7 +81,7 @@ dumpmetadata(int ncid, NChdr** hdrp)
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
|
||||
hdr->dims = (Dim*)malloc(hdr->ndims*sizeof(Dim));
|
||||
hdr->dims = (Dim*)malloc((size_t)hdr->ndims*sizeof(Dim));
|
||||
MEMCHECK(hdr->dims,NC_ENOMEM);
|
||||
for(i=0;i<hdr->ndims;i++) {
|
||||
hdr->dims[i].dimid = i;
|
||||
@ -93,7 +93,7 @@ dumpmetadata(int ncid, NChdr** hdrp)
|
||||
fprintf(stdout,"dim[%d]: name=%s size=%lu\n",
|
||||
i,hdr->dims[i].name,(unsigned long)hdr->dims[i].size);
|
||||
}
|
||||
hdr->vars = (Var*)malloc(hdr->nvars*sizeof(Var));
|
||||
hdr->vars = (Var*)malloc((size_t)hdr->nvars*sizeof(Var));
|
||||
MEMCHECK(hdr->vars,NC_ENOMEM);
|
||||
for(i=0;i<hdr->nvars;i++) {
|
||||
Var* var = &hdr->vars[i];
|
||||
@ -118,7 +118,7 @@ dumpmetadata(int ncid, NChdr** hdrp)
|
||||
fprintf(stdout," %d",var->dimids[j]);
|
||||
}
|
||||
fprintf(stdout,"}\n");
|
||||
var->atts = (NCattribute*)malloc(var->natts*sizeof(NCattribute));
|
||||
var->atts = (NCattribute*)malloc((size_t)var->natts*sizeof(NCattribute));
|
||||
MEMCHECK(var->atts,NC_ENOMEM);
|
||||
for(j=0;j<var->natts;j++) {
|
||||
NCattribute* att = &var->atts[j];
|
||||
|
@ -81,7 +81,7 @@ dapodom_print(Dapodometer* odom)
|
||||
if(odom->rank == 0) {
|
||||
strlcat(line,"[]",sizeof(line));
|
||||
} else for(i=0;i<odom->rank;i++) {
|
||||
sprintf(tmp,"[%lu/%lu:%lu:%lu]",
|
||||
snprintf(tmp,sizeof(tmp),"[%lu/%lu:%lu:%lu]",
|
||||
(size_t)odom->index[i],
|
||||
(size_t)odom->start[i],
|
||||
(size_t)odom->stride[i],
|
||||
|
@ -4,6 +4,7 @@
|
||||
*********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
@ -763,7 +764,7 @@ repairname(const char* name, const char* badchars)
|
||||
const char *p;
|
||||
char *q;
|
||||
int c;
|
||||
int nnlen = 0;
|
||||
size_t nnlen = 0;
|
||||
|
||||
if(name == NULL) return NULL;
|
||||
nnlen = (3*strlen(name)); /* max needed */
|
||||
|
@ -978,7 +978,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Avoid sprintf, as that infringes on the user's name space.
|
||||
/* Avoid snprintf, as that infringes on the user's name space.
|
||||
Don't have undefined behavior even if the translation
|
||||
produced a string with the wrong number of "%s"s. */
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "ncd4dispatch.h"
|
||||
#include "d4includes.h"
|
||||
#include "d4curlfunctions.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <process.h>
|
||||
@ -301,7 +302,7 @@ set_curl_properties(NCD4INFO* d4info)
|
||||
/* If no cookie file was defined, define a default */
|
||||
char* path = NULL;
|
||||
char* newpath = NULL;
|
||||
int len;
|
||||
size_t len;
|
||||
errno = 0;
|
||||
NCglobalstate* globalstate = NC_getglobalstate();
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "d4includes.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include "nc4internal.h"
|
||||
#include "ncoffsets.h"
|
||||
|
||||
@ -603,8 +604,8 @@ savevarbyid(NCD4node* group, NCD4node* var)
|
||||
{
|
||||
if(group->group.varbyid == NULL)
|
||||
group->group.varbyid = nclistnew();
|
||||
nclistsetalloc(group->group.varbyid,var->meta.id);
|
||||
nclistinsert(group->group.varbyid,var->meta.id,var);
|
||||
nclistsetalloc(group->group.varbyid, (size_t)var->meta.id);
|
||||
nclistinsert(group->group.varbyid, (size_t)var->meta.id,var);
|
||||
}
|
||||
|
||||
/* Collect FQN path from var node up to and including
|
||||
@ -730,7 +731,7 @@ compileAttrValues(NCD4meta* builder, NCD4node* attr, void** memoryp, NClist* blo
|
||||
NCD4node* container = attr->container;
|
||||
NCD4node* basetype = attr->basetype;
|
||||
NClist* values = attr->attr.values;
|
||||
int count = nclistlength(values);
|
||||
size_t count = nclistlength(values);
|
||||
|
||||
memset((void*)&converter,0,sizeof(converter));
|
||||
|
||||
|
@ -78,7 +78,7 @@ d4odom_print(D4odometer* odom)
|
||||
if(odom->rank == 0) {
|
||||
strlcat(line,"[]",sizeof(line));
|
||||
} else for(i=0;i<odom->rank;i++) {
|
||||
sprintf(tmp,"[%lu/%lu:%lu:%lu]",
|
||||
snprintf(tmp,sizeof(tmp),"[%lu/%lu:%lu:%lu]",
|
||||
(size_t)odom->index[i],
|
||||
(size_t)odom->start[i],
|
||||
(size_t)odom->stride[i],
|
||||
|
@ -51,7 +51,9 @@ IF(ENABLE_S3)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
BUILD_BIN_TEST(ncrandom)
|
||||
IF(ENABLE_TESTS)
|
||||
BUILD_BIN_TEST(ncrandom)
|
||||
ENDIF()
|
||||
|
||||
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
|
||||
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
|
||||
|
@ -694,7 +694,7 @@ searchgrouptree(int ncid1, int tid1, int grp, int* tid2)
|
||||
int gid;
|
||||
uintptr_t id;
|
||||
|
||||
id = grp;
|
||||
id = (uintptr_t)grp;
|
||||
nclistpush(queue,(void*)id); /* prime the queue */
|
||||
while(nclistlength(queue) > 0) {
|
||||
id = (uintptr_t)nclistremove(queue,0);
|
||||
@ -712,7 +712,7 @@ searchgrouptree(int ncid1, int tid1, int grp, int* tid2)
|
||||
goto done;
|
||||
/* push onto the end of the queue */
|
||||
for(i=0;i<nids;i++) {
|
||||
id = ids[i];
|
||||
id = (uintptr_t)ids[i];
|
||||
nclistpush(queue,(void*)id);
|
||||
}
|
||||
free(ids); ids = NULL;
|
||||
|
@ -260,10 +260,7 @@ local const z_crc_t FAR * ZEXPORT get_crc_table()
|
||||
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long ZEXPORT crc32_z(crc, buf, len)
|
||||
unsigned long crc;
|
||||
const unsigned char FAR *buf;
|
||||
z_size_t len;
|
||||
local unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
|
||||
{
|
||||
if (buf == Z_NULL) return 0UL;
|
||||
|
||||
|
0
libdispatch/dcrc32.h
Executable file → Normal file
0
libdispatch/dcrc32.h
Executable file → Normal file
@ -267,9 +267,9 @@ const char *nc_strerror(int ncerr1)
|
||||
case NC_EMPI: return "NetCDF: MPI operation failed.";
|
||||
case NC_ERCFILE:
|
||||
return "NetCDF: RC File Failure.";
|
||||
case NC_ENULLPAD:
|
||||
case NC_ENULLPAD:
|
||||
return "NetCDF: File fails strict Null-Byte Header check.";
|
||||
case NC_EINMEMORY:
|
||||
case NC_EINMEMORY:
|
||||
return "NetCDF: In-memory File operation failed.";
|
||||
case NC_ENCZARR:
|
||||
return "NetCDF: NCZarr error";
|
||||
|
@ -320,8 +320,8 @@ parsepair(const char* pair, char** keyp, char** valuep)
|
||||
key = strdup(pair);
|
||||
} else {
|
||||
ptrdiff_t len = (p-pair);
|
||||
if((key = malloc(len+1))==NULL) return NC_ENOMEM;
|
||||
memcpy(key,pair,len);
|
||||
if((key = malloc((size_t)len+1))==NULL) return NC_ENOMEM;
|
||||
memcpy(key,pair,(size_t)len);
|
||||
key[len] = '\0';
|
||||
if(p[1] == '\0')
|
||||
value = NULL;
|
||||
@ -383,8 +383,8 @@ parseonchar(const char* s, int ch, NClist* segments)
|
||||
endp = strchr(p,ch);
|
||||
if(endp == NULL) endp = p + strlen(p);
|
||||
slen = (endp - p);
|
||||
if((q = malloc(slen+1)) == NULL) {stat = NC_ENOMEM; goto done;}
|
||||
memcpy(q,p,slen);
|
||||
if((q = malloc((size_t)slen+1)) == NULL) {stat = NC_ENOMEM; goto done;}
|
||||
memcpy(q,p,(size_t)slen);
|
||||
q[slen] = '\0';
|
||||
nclistpush(segments,q);
|
||||
if(*endp == '\0') break;
|
||||
|
@ -76,7 +76,7 @@ parallel I/O.
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
|
||||
|
||||
sprintf(file_name, "%s/%s", TEMP_LARGE, FILE);
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", TEMP_LARGE, FILE);
|
||||
if ((res = nc_create_par(file_name, NC_NETCDF4, comm, info, &ncid))) ERR;
|
||||
|
||||
if (nc_def_dim(ncid, "d1", DIMSIZE, dimids)) ERR;
|
||||
@ -331,7 +331,7 @@ nc_open_par_fortran(const char *path, int omode, int comm,
|
||||
@return ::NC_NOERR No error.
|
||||
@return ::NC_EBADID Invalid ncid passed.
|
||||
@return ::NC_ENOTVAR Invalid varid passed.
|
||||
@return ::NC_ENOPAR File was not opened with nc_open_par/nc_create_var.
|
||||
@return ::NC_ENOPAR File was not opened with nc_open_par/nc_create_par.
|
||||
@return ::NC_EINVAL Invalid par_access specified, or attempt to set
|
||||
filtered variable to independent access.
|
||||
|
||||
|
@ -448,9 +448,9 @@ NC_split_delim(const char* arg, char delim, NClist* segments)
|
||||
len = (q - p);
|
||||
if(len == 0)
|
||||
{stat = NC_EURL; goto done;}
|
||||
if((seg = malloc(len+1)) == NULL)
|
||||
if((seg = malloc((size_t)len+1)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
memcpy(seg,p,len);
|
||||
memcpy(seg,p,(size_t)len);
|
||||
seg[len] = '\0';
|
||||
nclistpush(segments,seg);
|
||||
seg = NULL; /* avoid mem errors */
|
||||
|
@ -1254,7 +1254,7 @@ ncvarputg(
|
||||
ret = nc_inq_vartype(ncid, varid, &type);
|
||||
if(ret) return ret;
|
||||
el_size = nctypelen(type);
|
||||
imp = (ptrdiff_t*) malloc(ndims * sizeof(ptrdiff_t));
|
||||
imp = (ptrdiff_t*) malloc((size_t)ndims * sizeof(ptrdiff_t));
|
||||
for (i=0; i<ndims; i++) imp[i] = map[i] / el_size;
|
||||
}
|
||||
|
||||
@ -1327,7 +1327,7 @@ ncvargetg(
|
||||
ret = nc_inq_vartype(ncid, varid, &type);
|
||||
if(ret) return ret;
|
||||
el_size = nctypelen(type);
|
||||
imp = (ptrdiff_t*) malloc(ndims * sizeof(ptrdiff_t));
|
||||
imp = (ptrdiff_t*) malloc((size_t)ndims * sizeof(ptrdiff_t));
|
||||
for (i=0; i<ndims; i++) imp[i] = map[i] / el_size;
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1034,7 @@ NC_inq_recvar(int ncid, int varid, int* nrecdimsp, int *is_recdim)
|
||||
if(status != NC_NOERR) return status;
|
||||
if(nunlimdims == 0) return status;
|
||||
|
||||
if (!(unlimids = malloc(nunlimdims * sizeof(int))))
|
||||
if (!(unlimids = malloc((size_t)nunlimdims * sizeof(int))))
|
||||
return NC_ENOMEM;
|
||||
status = nc_inq_unlimdims(ncid, &nunlimdims, unlimids); /* for group or file, not variable */
|
||||
if(status != NC_NOERR) {
|
||||
@ -1263,7 +1263,7 @@ NC_check_nulls(int ncid, int varid, const size_t *start, size_t **count,
|
||||
/* If count is NULL, assume full extent of var. */
|
||||
if (!*count)
|
||||
{
|
||||
if (!(*count = malloc(varndims * sizeof(size_t))))
|
||||
if (!(*count = malloc((size_t)varndims * sizeof(size_t))))
|
||||
return NC_ENOMEM;
|
||||
if ((stat = NC_getshape(ncid, varid, varndims, *count)))
|
||||
{
|
||||
@ -1279,7 +1279,7 @@ NC_check_nulls(int ncid, int varid, const size_t *start, size_t **count,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!(*stride = malloc(varndims * sizeof(ptrdiff_t))))
|
||||
if (!(*stride = malloc((size_t)varndims * sizeof(ptrdiff_t))))
|
||||
return NC_ENOMEM;
|
||||
for (i = 0; i < varndims; i++)
|
||||
(*stride)[i] = 1;
|
||||
|
@ -386,7 +386,7 @@ exhashsplit(NCexhashmap* map, ncexhashkey_t hkey, NCexleaf* leaf)
|
||||
}
|
||||
|
||||
/* Re-build the old leaf; keep same uid */
|
||||
if((leaf->entries = (NCexentry*)calloc(map->leaflen,sizeof(NCexentry))) == NULL)
|
||||
if((leaf->entries = (NCexentry*)calloc((size_t)map->leaflen, sizeof(NCexentry))) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
leaf->active = 0;
|
||||
|
||||
@ -588,7 +588,7 @@ exhashnewleaf(NCexhashmap* map, NCexleaf** leafp)
|
||||
if((leaf = calloc(1,sizeof(NCexleaf))) == NULL)
|
||||
goto done;
|
||||
assert(map->leaflen > 0);
|
||||
if((leaf->entries = calloc(map->leaflen,sizeof(NCexentry))) == NULL)
|
||||
if((leaf->entries = calloc((size_t)map->leaflen, sizeof(NCexentry))) == NULL)
|
||||
goto done;
|
||||
leaf->uid = map->uid++;
|
||||
*leafp = leaf; leaf = NULL;
|
||||
|
@ -1152,7 +1152,7 @@ NCH5_s3comms_s3r_open(const char* root, NCS3SVC svc, const char *region, const c
|
||||
/* Compute the signing key */
|
||||
if (SUCCEED != NCH5_s3comms_signing_key(&signing_key, access_key, region, iso8601now))
|
||||
HGOTO_ERROR(H5E_ARGS, NC_EINVAL, NULL, "problem in NCH5_s3comms_s3comms_signing_key.");
|
||||
if (nulllen(signing_key)==0)
|
||||
if (signing_key == NULL)
|
||||
HGOTO_ERROR(H5E_ARGS, NC_EAUTH, NULL, "signing key cannot be null.");
|
||||
handle->signing_key = signing_key;
|
||||
signing_key = NULL;
|
||||
@ -2033,7 +2033,7 @@ NCH5_s3comms_signing_key(unsigned char **mdp, const char *secret, const char *re
|
||||
if ((size_t)ret != (AWS4_secret_len - 1))
|
||||
HGOTO_ERRORVA(H5E_ARGS, NC_EINVAL, FAIL, "problem writing AWS4+secret `%s`", secret);
|
||||
|
||||
if((md = (unsigned char*)malloc(SHA256_DIGEST_LENGTH))==NULL)
|
||||
if((md = (unsigned char*)calloc(1,SHA256_DIGEST_LENGTH))==NULL)
|
||||
HGOTO_ERROR(H5E_ARGS, NC_ENOMEM, NULL, "could not malloc space for signing key .");
|
||||
|
||||
/* hash_func, key, len(key), msg, len(msg), digest_dest, digest_len_dest
|
||||
|
@ -798,9 +798,9 @@ listappend(struct NCjlist* list, NCjson* json)
|
||||
list->contents[0] = json;
|
||||
list->len++;
|
||||
} else {
|
||||
if((newcontents = (NCjson**)calloc((2*list->len)+1,sizeof(NCjson*)))==NULL)
|
||||
if((newcontents = (NCjson**)calloc((size_t)(2*list->len)+1,sizeof(NCjson*)))==NULL)
|
||||
{stat = NCJTHROW(NCJ_ERR); goto done;}
|
||||
memcpy(newcontents,list->contents,list->len*sizeof(NCjson*));
|
||||
memcpy(newcontents,list->contents, (size_t)list->len*sizeof(NCjson*));
|
||||
newcontents[list->len] = json;
|
||||
list->len++;
|
||||
free(list->contents);
|
||||
|
@ -31,7 +31,7 @@ NClist* nclistnew(void)
|
||||
ncinitialized = 1;
|
||||
}
|
||||
*/
|
||||
l = (NClist*)malloc(sizeof(NClist));
|
||||
l = (NClist*)calloc(1,sizeof(NClist));
|
||||
if(l) {
|
||||
l->alloc=0;
|
||||
l->length=0;
|
||||
@ -286,10 +286,13 @@ done:
|
||||
void*
|
||||
nclistextract(NClist* l)
|
||||
{
|
||||
void* result = l->content;
|
||||
void* result = NULL;
|
||||
if(l) {
|
||||
result = l->content;
|
||||
l->alloc = 0;
|
||||
l->length = 0;
|
||||
l->content = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTi
|
||||
else{
|
||||
cdTrim(basetime_1,CD_MAX_CHARTIME);
|
||||
cdTrim(basetime_2,CD_MAX_CHARTIME);
|
||||
sprintf(basetime,"%s %s",basetime_1,basetime_2);
|
||||
snprintf(basetime,sizeof(basetime),"%s %s",basetime_1,basetime_2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1085,7 +1085,7 @@ cdRel2Comp(cdCalenType timetype, char* relunits, double reltime, cdCompTime* com
|
||||
|
||||
/* rkr: output as ISO 8601 strings */
|
||||
static void
|
||||
cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time)
|
||||
cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time, size_t time_size)
|
||||
{
|
||||
double dtmp, sec;
|
||||
int ihr, imin, isec;
|
||||
@ -1121,23 +1121,23 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time)
|
||||
if(timetype & cdStandardCal){
|
||||
switch (nskip) {
|
||||
case 0: /* sec != 0 && (int)sec != sec */
|
||||
sprintf(time,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d:%lf",
|
||||
snprintf(time,time_size,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d:%lf",
|
||||
comptime.year,comptime.month,comptime.day,separator,ihr,imin,sec);
|
||||
break;
|
||||
case 1:
|
||||
sprintf(time,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d:%2.2d",
|
||||
snprintf(time,time_size,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d:%2.2d",
|
||||
comptime.year,comptime.month,comptime.day,separator,ihr,imin,isec);
|
||||
break;
|
||||
case 2:
|
||||
sprintf(time,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d",
|
||||
snprintf(time,time_size,"%4.4ld-%2.2hd-%2.2hd%c%2.2d:%2.2d",
|
||||
comptime.year,comptime.month,comptime.day,separator,ihr,imin);
|
||||
break;
|
||||
case 3:
|
||||
sprintf(time,"%4.4ld-%2.2hd-%2.2hd%c%2.2d",
|
||||
snprintf(time,time_size,"%4.4ld-%2.2hd-%2.2hd%c%2.2d",
|
||||
comptime.year,comptime.month,comptime.day,separator,ihr);
|
||||
break;
|
||||
case 4:
|
||||
sprintf(time,"%4.4ld-%2.2hd-%2.2hd",
|
||||
snprintf(time,time_size,"%4.4ld-%2.2hd-%2.2hd",
|
||||
comptime.year,comptime.month,comptime.day);
|
||||
break;
|
||||
}
|
||||
@ -1145,23 +1145,23 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time)
|
||||
else { /* Climatological */
|
||||
switch (nskip) {
|
||||
case 0: /* sec != 0 && (int)sec != sec */
|
||||
sprintf(time,"%2.2hd-%2.2hd%c%2.2d:%2.2d:%lf",
|
||||
snprintf(time,time_size,"%2.2hd-%2.2hd%c%2.2d:%2.2d:%lf",
|
||||
comptime.month,comptime.day,separator,ihr,imin,sec);
|
||||
break;
|
||||
case 1:
|
||||
sprintf(time,"%2.2hd-%2.2hd%c%2.2d:%2.2d:%2.2d",
|
||||
snprintf(time,time_size,"%2.2hd-%2.2hd%c%2.2d:%2.2d:%2.2d",
|
||||
comptime.month,comptime.day,separator,ihr,imin,isec);
|
||||
break;
|
||||
case 2:
|
||||
sprintf(time,"%2.2hd-%2.2hd%c%2.2d:%2.2d",
|
||||
snprintf(time,time_size,"%2.2hd-%2.2hd%c%2.2d:%2.2d",
|
||||
comptime.month,comptime.day,separator,ihr,imin);
|
||||
break;
|
||||
case 3:
|
||||
sprintf(time,"%2.2hd-%2.2hd%c%2.2d",
|
||||
snprintf(time,time_size,"%2.2hd-%2.2hd%c%2.2d",
|
||||
comptime.month,comptime.day,separator,ihr);
|
||||
break;
|
||||
case 4:
|
||||
sprintf(time,"%2.2hd-%2.2hd",
|
||||
snprintf(time,time_size,"%2.2hd-%2.2hd",
|
||||
comptime.month,comptime.day);
|
||||
break;
|
||||
}
|
||||
@ -1171,12 +1171,12 @@ cdComp2Iso(cdCalenType timetype, int separator, cdCompTime comptime, char* time)
|
||||
|
||||
/* rkr: added for output closer to ISO 8601 */
|
||||
void
|
||||
cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime)
|
||||
cdRel2Iso(cdCalenType timetype, char* relunits, int separator, double reltime, char* chartime, size_t chartime_size)
|
||||
{
|
||||
cdCompTime comptime;
|
||||
|
||||
cdRel2Comp(timetype, relunits, reltime, &comptime);
|
||||
cdComp2Iso(timetype, separator, comptime, chartime);
|
||||
cdComp2Iso(timetype, separator, comptime, chartime, chartime_size);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ static nc_utf8proc_ssize_t nc_seqindex_write_char_decomposed(nc_utf8proc_uint16_
|
||||
*dstptr = NULL;
|
||||
result = nc_utf8proc_decompose_custom(str, strlen, NULL, 0, options, custom_func, custom_data);
|
||||
if (result < 0) return result;
|
||||
buffer = (nc_utf8proc_int32_t *) malloc(result * sizeof(nc_utf8proc_int32_t) + 1);
|
||||
buffer = (nc_utf8proc_int32_t *) malloc((size_t)result * sizeof(nc_utf8proc_int32_t) + 1);
|
||||
if (!buffer) return UTF8PROC_ERROR_NOMEM;
|
||||
result = nc_utf8proc_decompose_custom(str, strlen, buffer, result, options, custom_func, custom_data);
|
||||
if (result < 0) {
|
||||
|
@ -239,6 +239,31 @@ H5FD_http_init(void)
|
||||
return H5FD_HTTP_g;
|
||||
} /* end H5FD_http_init() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FD_http_finalize
|
||||
*
|
||||
* Purpose: Free this driver by unregistering the driver with the
|
||||
* library.
|
||||
*
|
||||
* Returns: Non-negative on success or negative on failure
|
||||
*
|
||||
* Programmer: John Donoghue
|
||||
* Tuesday, December 12, 2023
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
EXTERNL hid_t
|
||||
H5FD_http_finalize(void)
|
||||
{
|
||||
/* Reset VFL ID */
|
||||
if (H5FD_HTTP_g)
|
||||
H5FDunregister(H5FD_HTTP_g);
|
||||
H5FD_HTTP_g = 0;
|
||||
|
||||
return H5FD_HTTP_g;
|
||||
} /* end H5FD_http_finalize() */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Function: H5FD_http_term
|
||||
@ -256,9 +281,6 @@ H5FD_http_init(void)
|
||||
static herr_t
|
||||
H5FD_http_term(void)
|
||||
{
|
||||
/* Reset VFL ID */
|
||||
H5FD_HTTP_g = 0;
|
||||
|
||||
return 0;
|
||||
} /* end H5FD_http_term() */
|
||||
#endif
|
||||
|
@ -44,9 +44,11 @@ extern "C" {
|
||||
|
||||
#if 0
|
||||
H5_DLL hid_t H5FD_http_init(void);
|
||||
H5_DLL hid_t H5FD_http_finalize(void);
|
||||
H5_DLL herr_t H5Pset_fapl_http(hid_t fapl_id);
|
||||
#else
|
||||
EXTERNL hid_t H5FD_http_init(void);
|
||||
EXTERNL hid_t H5FD_http_finalize(void);
|
||||
EXTERNL herr_t H5Pset_fapl_http(hid_t fapl_id);
|
||||
#endif
|
||||
|
||||
|
@ -142,6 +142,9 @@ NC_HDF5_initialize(void)
|
||||
int
|
||||
NC_HDF5_finalize(void)
|
||||
{
|
||||
#ifdef ENABLE_BYTERANGE
|
||||
(void)H5FD_http_finalize();
|
||||
#endif
|
||||
(void)nc4_hdf5_finalize();
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
@ -150,9 +150,9 @@ find_var_dim_max_length(NC_GRP_INFO_T *grp, int varid, int dimid,
|
||||
BAIL(NC_EHDFERR);
|
||||
if (dataset_ndims != var->ndims)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (!(h5dimlen = malloc(dataset_ndims * sizeof(hsize_t))))
|
||||
if (!(h5dimlen = malloc((size_t)dataset_ndims * sizeof(hsize_t))))
|
||||
BAIL(NC_ENOMEM);
|
||||
if (!(h5dimlenmax = malloc(dataset_ndims * sizeof(hsize_t))))
|
||||
if (!(h5dimlenmax = malloc((size_t)dataset_ndims * sizeof(hsize_t))))
|
||||
BAIL(NC_ENOMEM);
|
||||
if ((dataset_ndims = H5Sget_simple_extent_dims(spaceid,
|
||||
h5dimlen, h5dimlenmax)) < 0)
|
||||
|
@ -482,7 +482,7 @@ create_phony_dims(NC_GRP_INFO_T *grp, hid_t hdf_datasetid, NC_VAR_INFO_T *var)
|
||||
if (!match)
|
||||
{
|
||||
char phony_dim_name[NC_MAX_NAME + 1];
|
||||
sprintf(phony_dim_name, "phony_dim_%d", grp->nc4_info->next_dimid);
|
||||
snprintf(phony_dim_name, sizeof(phony_dim_name), "phony_dim_%d", grp->nc4_info->next_dimid);
|
||||
LOG((3, "%s: creating phony dim for var %s", __func__, var->hdr.name));
|
||||
|
||||
/* Add phony dim to metadata list. */
|
||||
@ -1365,9 +1365,9 @@ get_attached_info(NC_VAR_INFO_T *var, NC_HDF5_VAR_INFO_T *hdf5_var, int ndims,
|
||||
* attached for each dimension, and the HDF5 object IDs of the
|
||||
* scale(s). */
|
||||
assert(!hdf5_var->dimscale_hdf5_objids);
|
||||
if (!(hdf5_var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
|
||||
if (!(hdf5_var->dimscale_attached = calloc((size_t)ndims, sizeof(nc_bool_t))))
|
||||
return NC_ENOMEM;
|
||||
if (!(hdf5_var->dimscale_hdf5_objids = malloc(ndims *
|
||||
if (!(hdf5_var->dimscale_hdf5_objids = malloc((size_t)ndims *
|
||||
sizeof(struct hdf5_objid))))
|
||||
return NC_ENOMEM;
|
||||
|
||||
@ -1886,7 +1886,7 @@ read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att)
|
||||
&type_size)))
|
||||
return retval;
|
||||
{
|
||||
if (!(att->data = malloc((unsigned int)(att->len * type_size))))
|
||||
if (!(att->data = malloc((unsigned int)((size_t)att->len * type_size))))
|
||||
BAIL(NC_ENOMEM);
|
||||
|
||||
/* For a fixed length HDF5 string, the read requires
|
||||
@ -1907,7 +1907,7 @@ read_hdf5_att(NC_GRP_INFO_T *grp, hid_t attid, NC_ATT_INFO_T *att)
|
||||
char** dst = NULL;
|
||||
|
||||
/* Alloc space for the contiguous memory read. */
|
||||
if (!(contig_buf = malloc(att->len * fixed_size * sizeof(char))))
|
||||
if (!(contig_buf = malloc((size_t)att->len * fixed_size * sizeof(char))))
|
||||
BAIL(NC_ENOMEM);
|
||||
|
||||
/* Read the fixed-len strings as one big block. */
|
||||
@ -2088,7 +2088,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
return NC_EHDFERR;
|
||||
LOG((5, "compound type has %d members", nmembers));
|
||||
type->u.c.field = nclistnew();
|
||||
nclistsetalloc(type->u.c.field,nmembers);
|
||||
nclistsetalloc(type->u.c.field, (size_t)nmembers);
|
||||
|
||||
for (m = 0; m < nmembers; m++)
|
||||
{
|
||||
@ -2253,7 +2253,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
if ((nmembers = H5Tget_nmembers(hdf_typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->u.e.enum_member = nclistnew();
|
||||
nclistsetalloc(type->u.e.enum_member,nmembers);
|
||||
nclistsetalloc(type->u.e.enum_member, (size_t)nmembers);
|
||||
|
||||
/* Allocate space for one value. */
|
||||
if (!(value = calloc(1, type_size)))
|
||||
|
@ -121,11 +121,12 @@ give_var_secret_name(NC_VAR_INFO_T *var, const char *name)
|
||||
* clash. */
|
||||
if (strlen(name) + strlen(NON_COORD_PREPEND) > NC_MAX_NAME)
|
||||
return NC_EMAXNAME;
|
||||
if (!(var->alt_name = malloc((strlen(NON_COORD_PREPEND) +
|
||||
strlen(name) + 1) * sizeof(char))))
|
||||
size_t alt_name_size = (strlen(NON_COORD_PREPEND) + strlen(name) + 1) *
|
||||
sizeof(char);
|
||||
if (!(var->alt_name = malloc(alt_name_size)))
|
||||
return NC_ENOMEM;
|
||||
|
||||
sprintf(var->alt_name, "%s%s", NON_COORD_PREPEND, name);
|
||||
snprintf(var->alt_name, alt_name_size, "%s%s", NON_COORD_PREPEND, name);
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
@ -433,7 +434,7 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, int ndims,
|
||||
* remember whether dimension scales have been attached to each
|
||||
* dimension. */
|
||||
if (!hdf5_var->dimscale && ndims)
|
||||
if (!(hdf5_var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
|
||||
if (!(hdf5_var->dimscale_attached = calloc((size_t)ndims, sizeof(nc_bool_t))))
|
||||
BAIL(NC_ENOMEM);
|
||||
|
||||
/* Return the varid. */
|
||||
@ -1541,11 +1542,12 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
NC_VAR_INFO_T *var;
|
||||
NC_DIM_INFO_T *dim;
|
||||
NC_HDF5_VAR_INFO_T *hdf5_var;
|
||||
herr_t herr;
|
||||
hid_t file_spaceid = 0, mem_spaceid = 0, xfer_plistid = 0;
|
||||
long long unsigned xtend_size[NC_MAX_VAR_DIMS];
|
||||
hsize_t fdims[NC_MAX_VAR_DIMS], fmaxdims[NC_MAX_VAR_DIMS];
|
||||
hsize_t start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
|
||||
hsize_t stride[NC_MAX_VAR_DIMS];
|
||||
hsize_t stride[NC_MAX_VAR_DIMS], ones[NC_MAX_VAR_DIMS];
|
||||
int need_to_extend = 0;
|
||||
#ifdef USE_PARALLEL4
|
||||
int extend_possible = 0;
|
||||
@ -1596,6 +1598,7 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[i] = startp[i];
|
||||
count[i] = countp ? countp[i] : var->dim[i]->len;
|
||||
stride[i] = stridep ? stridep[i] : 1;
|
||||
ones[i] = 1;
|
||||
LOG((4, "start[%d] %ld count[%d] %ld stride[%d] %ld", i, start[i], i, count[i], i, stride[i]));
|
||||
|
||||
/* Check to see if any counts are zero. */
|
||||
@ -1646,8 +1649,13 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, stride,
|
||||
count, NULL) < 0)
|
||||
if (stridep == NULL)
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start,
|
||||
NULL, ones, count);
|
||||
else
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start,
|
||||
stride, count, NULL);
|
||||
if (herr < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Create a space for the memory, just big enough to hold the slab
|
||||
@ -1772,8 +1780,14 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
BAIL2(NC_EHDFERR);
|
||||
if ((file_spaceid = H5Dget_space(hdf5_var->hdf_datasetid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, count, NULL) < 0)
|
||||
|
||||
if (stridep == NULL)
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, ones, count);
|
||||
else
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, count, NULL);
|
||||
if (herr < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
}
|
||||
@ -1872,7 +1886,7 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
hsize_t count[NC_MAX_VAR_DIMS];
|
||||
hsize_t fdims[NC_MAX_VAR_DIMS], fmaxdims[NC_MAX_VAR_DIMS];
|
||||
hsize_t start[NC_MAX_VAR_DIMS];
|
||||
hsize_t stride[NC_MAX_VAR_DIMS];
|
||||
hsize_t stride[NC_MAX_VAR_DIMS], ones[NC_MAX_VAR_DIMS];
|
||||
void *fillvalue = NULL;
|
||||
int no_read = 0, provide_fill = 0;
|
||||
hssize_t fill_value_size[NC_MAX_VAR_DIMS];
|
||||
@ -1923,6 +1937,7 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[i] = startp[i];
|
||||
count[i] = countp[i];
|
||||
stride[i] = stridep ? stridep[i] : 1;
|
||||
ones[i] = 1;
|
||||
|
||||
/* if any of the count values are zero don't actually read. */
|
||||
if (count[i] == 0)
|
||||
@ -2052,9 +2067,16 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, count, NULL) < 0)
|
||||
herr_t herr;
|
||||
if (stridep == NULL)
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, NULL, ones, count);
|
||||
else
|
||||
herr = H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, count, NULL);
|
||||
if (herr < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Create a space for the memory, just big enough to hold the slab
|
||||
we want. */
|
||||
if ((mem_spaceid = H5Screate_simple(var->ndims, count, NULL)) < 0)
|
||||
|
@ -702,13 +702,13 @@ write_quantize_att(NC_VAR_INFO_T *var)
|
||||
switch (var->quantize_mode)
|
||||
{
|
||||
case NC_QUANTIZE_BITGROOM:
|
||||
sprintf(att_name, "%s", NC_QUANTIZE_BITGROOM_ATT_NAME);
|
||||
snprintf(att_name, sizeof(att_name), "%s", NC_QUANTIZE_BITGROOM_ATT_NAME);
|
||||
break;
|
||||
case NC_QUANTIZE_GRANULARBR:
|
||||
sprintf(att_name, "%s", NC_QUANTIZE_GRANULARBR_ATT_NAME);
|
||||
snprintf(att_name, sizeof(att_name), "%s", NC_QUANTIZE_GRANULARBR_ATT_NAME);
|
||||
break;
|
||||
case NC_QUANTIZE_BITROUND:
|
||||
sprintf(att_name, "%s", NC_QUANTIZE_BITROUND_ATT_NAME);
|
||||
snprintf(att_name, sizeof(att_name), "%s", NC_QUANTIZE_BITROUND_ATT_NAME);
|
||||
break;
|
||||
default:
|
||||
return NC_EINVAL;
|
||||
@ -1826,7 +1826,7 @@ nc4_create_dim_wo_var(NC_DIM_INFO_T *dim)
|
||||
/* Indicate that this is a scale. Also indicate that not
|
||||
* be shown to the user as a variable. It is hidden. It is
|
||||
* a DIM WITHOUT A VARIABLE! */
|
||||
sprintf(dimscale_wo_var, "%s%10d", DIM_WITHOUT_VARIABLE, (int)dim->len);
|
||||
snprintf(dimscale_wo_var, sizeof(dimscale_wo_var), "%s%10d", DIM_WITHOUT_VARIABLE, (int)dim->len);
|
||||
if (H5DSset_scale(hdf5_dim->hdf_dimscaleid, dimscale_wo_var) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
@ -2257,7 +2257,7 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp)
|
||||
if (match < 0)
|
||||
{
|
||||
char phony_dim_name[NC_MAX_NAME + 1];
|
||||
sprintf(phony_dim_name, "phony_dim_%d", grp->nc4_info->next_dimid);
|
||||
snprintf(phony_dim_name, sizeof(phony_dim_name), "phony_dim_%d", grp->nc4_info->next_dimid);
|
||||
LOG((3, "%s: creating phony dim for var %s", __func__, var->hdr.name));
|
||||
if ((retval = nc4_dim_list_add(grp, phony_dim_name, h5dimlen[d], -1, &dim)))
|
||||
{
|
||||
|
@ -57,6 +57,10 @@ IF(STATUS_PARALLEL)
|
||||
target_link_libraries(netcdf MPI::MPI_C)
|
||||
ENDIF(STATUS_PARALLEL)
|
||||
|
||||
IF(TARGET MPI::MPI_C)
|
||||
target_link_libraries(netcdf MPI::MPI_C)
|
||||
ENDIF(TARGET MPI::MPI_C)
|
||||
|
||||
IF(MOD_NETCDF_NAME)
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES LIBRARY_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
SET_TARGET_PROPERTIES(netcdf PROPERTIES ARCHIVE_OUTPUT_NAME ${NETCDF_LIB_NAME})
|
||||
@ -96,7 +100,7 @@ IF(Bz2_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Bz2_LIBRARIES})
|
||||
ENDIF()
|
||||
IF(SZIP_FOUND)
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${SZIP_LIBRARIES})
|
||||
SET(TLL_LIBS ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ENDIF()
|
||||
|
||||
IF(HAVE_LIBDL)
|
||||
@ -121,9 +125,9 @@ IF(USE_HDF5)
|
||||
# builds:
|
||||
# Make sure that HDF5_C_LIBRARY appears *after*
|
||||
# HDF5_HL_LIBRARY.
|
||||
SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
|
||||
SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ELSE() # Windows CMake defines HDF5_LIBRARIES.
|
||||
SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
|
||||
SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${Szip_LIBRARY})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
0
libncpoco/CMakeLists.txt
Executable file → Normal file
0
libncpoco/CMakeLists.txt
Executable file → Normal file
0
libncpoco/COPYRIGHT
Executable file → Normal file
0
libncpoco/COPYRIGHT
Executable file → Normal file
0
libncpoco/Makefile.am
Executable file → Normal file
0
libncpoco/Makefile.am
Executable file → Normal file
0
libncpoco/cp_test.c
Executable file → Normal file
0
libncpoco/cp_test.c
Executable file → Normal file
2
libncpoco/cp_unix.c
Executable file → Normal file
2
libncpoco/cp_unix.c
Executable file → Normal file
@ -46,7 +46,7 @@ static void
|
||||
ncperr(const char* fcn, NCPSharedLib* lib)
|
||||
{
|
||||
const char* msg = dlerror();
|
||||
lib->err.msg[0] = '\0';
|
||||
memset(lib->err.msg,0,sizeof(lib->err.msg));
|
||||
if(msg != NULL) {
|
||||
strlcat(lib->err.msg,fcn,sizeof(lib->err.msg));
|
||||
strlcat(lib->err.msg,": ",sizeof(lib->err.msg));
|
||||
|
5
libncpoco/cp_win32.c
Executable file → Normal file
5
libncpoco/cp_win32.c
Executable file → Normal file
@ -105,10 +105,9 @@ load(NCPSharedLib* lib , const char* path0, int flags)
|
||||
char* msg = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &msg, 0, NULL);
|
||||
if(msg) {
|
||||
memset(lib->err.msg,0,sizeof(lib->err.msg));
|
||||
if(msg)
|
||||
strncpy(lib->err.msg,msg,sizeof(lib->err.msg));
|
||||
} else
|
||||
lib->err.msg[0] = '\0';
|
||||
ret = NC_ENOTFOUND;
|
||||
goto ldone;
|
||||
}
|
||||
|
0
libncpoco/cptestlib.c
Executable file → Normal file
0
libncpoco/cptestlib.c
Executable file → Normal file
11
libncpoco/ncpoco.c
Executable file → Normal file
11
libncpoco/ncpoco.c
Executable file → Normal file
@ -68,6 +68,7 @@ EXTERNL int
|
||||
ncpload(NCPSharedLib* lib, const char* path, int flags)
|
||||
{
|
||||
if(lib == NULL || path == NULL) return NC_EINVAL;
|
||||
ncpclearerrmsg(lib);
|
||||
return lib->api.load(lib,path,flags);
|
||||
}
|
||||
|
||||
@ -75,6 +76,7 @@ EXTERNL int
|
||||
ncpunload(NCPSharedLib* lib) /* Unloads a shared library. */
|
||||
{
|
||||
if(lib == NULL) return NC_EINVAL;
|
||||
ncpclearerrmsg(lib);
|
||||
return lib->api.unload(lib);
|
||||
}
|
||||
|
||||
@ -93,6 +95,7 @@ EXTERNL void*
|
||||
ncpgetsymbol(NCPSharedLib* lib,const char* name)
|
||||
{
|
||||
if(lib == NULL) return NULL;
|
||||
ncpclearerrmsg(lib);
|
||||
return lib->api.getsymbol(lib,name);
|
||||
}
|
||||
|
||||
@ -113,3 +116,11 @@ ncpgeterrmsg(NCPSharedLib* lib)
|
||||
if(lib == NULL) return NULL;
|
||||
return (lib->err.msg[0] == '\0' ? NULL : lib->err.msg);
|
||||
}
|
||||
|
||||
/* Clear the last err msg. */
|
||||
EXTERNL void
|
||||
ncpclearerrmsg(NCPSharedLib* lib)
|
||||
{
|
||||
if(lib == NULL) return;
|
||||
memset(lib->err.msg,0,sizeof(lib->err.msg));
|
||||
}
|
||||
|
3
libncpoco/ncpoco.h
Executable file → Normal file
3
libncpoco/ncpoco.h
Executable file → Normal file
@ -71,6 +71,9 @@ EXTERNL const char* ncpgetpath(NCPSharedLib*);
|
||||
/* Return last err msg */
|
||||
EXTERNL const char* ncpgeterrmsg(NCPSharedLib* lib);
|
||||
|
||||
/* Clear the last err msg. */
|
||||
EXTERNL void ncpclearerrmsg(NCPSharedLib* lib);
|
||||
|
||||
EXTERNL const char* intstr(int err1);
|
||||
|
||||
#endif /*NCPOCO_H*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* Copyright 2018-2018 University Corporation for Atmospheric Research/Unidata. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libxml2/libxml/parser.h>
|
||||
@ -139,7 +140,8 @@ ncxml_attr_pairs(ncxml_t xml0, char*** pairsp)
|
||||
char** pairs = NULL;
|
||||
xmlNode* xml = (xmlNode*)xml0;
|
||||
xmlAttr* attr = NULL;
|
||||
int i,count = 0;
|
||||
int i;
|
||||
size_t count = 0;
|
||||
|
||||
if(xml == NULL) return 0;
|
||||
/* First count */
|
||||
|
@ -322,8 +322,8 @@ nczm_divide_at(const char* key, int nsegs, char** prefixp, char** suffixp)
|
||||
/* p should point at the presegs+1 start point */
|
||||
delta = (p-key);
|
||||
if(prefixp) {
|
||||
prefix = malloc(delta+1);
|
||||
memcpy(prefix,key,delta);
|
||||
prefix = malloc((size_t)delta+1);
|
||||
memcpy(prefix,key,(size_t)delta);
|
||||
prefix[delta] = '\0';
|
||||
*prefixp = prefix;
|
||||
}
|
||||
@ -436,7 +436,7 @@ nczm_segment1(const char* path, char** seg1p)
|
||||
q = strchr(p,'/');
|
||||
if(q == NULL) q = p+strlen(p); /* point to stop character */
|
||||
delta = (q-p);
|
||||
if((seg1 = (char*)malloc(delta+1))==NULL)
|
||||
if((seg1 = (char*)malloc((size_t)delta+1))==NULL)
|
||||
{ret = NC_ENOMEM; goto done;}
|
||||
memcpy(seg1,p,delta);
|
||||
seg1[delta] = '\0';
|
||||
@ -489,9 +489,9 @@ nczm_basename(const char* path, char** basep)
|
||||
p = strrchr(last,'.');
|
||||
if(p == NULL) p = last+strlen(last);
|
||||
delta = (p - last);
|
||||
if((base = (char*)malloc(delta+1))==NULL)
|
||||
if((base = (char*)malloc((size_t)delta+1))==NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
memcpy(base,last,delta);
|
||||
memcpy(base,last,(size_t)delta);
|
||||
base[delta] = '\0';
|
||||
if(basep) {*basep = base; base = NULL;}
|
||||
done:
|
||||
|
0
libnczarr/zmap_file.c
Executable file → Normal file
0
libnczarr/zmap_file.c
Executable file → Normal file
0
libnczarr/zmap_zip.c
Executable file → Normal file
0
libnczarr/zmap_zip.c
Executable file → Normal file
@ -131,11 +131,11 @@ buildodom(int rank, NCZOdometer** odomp)
|
||||
if((odom = calloc(1,sizeof(NCZOdometer))) == NULL)
|
||||
goto done;
|
||||
odom->rank = rank;
|
||||
if((odom->start=calloc(1,(sizeof(size64_t)*rank)))==NULL) goto nomem;
|
||||
if((odom->stop=calloc(1,(sizeof(size64_t)*rank)))==NULL) goto nomem;
|
||||
if((odom->stride=calloc(1,(sizeof(size64_t)*rank)))==NULL) goto nomem;
|
||||
if((odom->len=calloc(1,(sizeof(size64_t)*rank)))==NULL) goto nomem;
|
||||
if((odom->index=calloc(1,(sizeof(size64_t)*rank)))==NULL) goto nomem;
|
||||
if((odom->start=calloc(1,(sizeof(size64_t)*(size_t)rank)))==NULL) goto nomem;
|
||||
if((odom->stop=calloc(1,(sizeof(size64_t)*(size_t)rank)))==NULL) goto nomem;
|
||||
if((odom->stride=calloc(1,(sizeof(size64_t)*(size_t)rank)))==NULL) goto nomem;
|
||||
if((odom->len=calloc(1,(sizeof(size64_t)*(size_t)rank)))==NULL) goto nomem;
|
||||
if((odom->index=calloc(1,(sizeof(size64_t)*(size_t)rank)))==NULL) goto nomem;
|
||||
*odomp = odom; odom = NULL;
|
||||
}
|
||||
done:
|
||||
|
@ -1676,7 +1676,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
|
||||
/* Save the rank of the variable */
|
||||
if((stat = nc4_var_set_ndims(var, rank))) goto done;
|
||||
/* extract the shapes */
|
||||
if((shapes = (size64_t*)malloc(sizeof(size64_t)*zarr_rank)) == NULL)
|
||||
if((shapes = (size64_t*)malloc(sizeof(size64_t)*(size_t)zarr_rank)) == NULL)
|
||||
{stat = (THROW(NC_ENOMEM)); goto done;}
|
||||
if((stat = decodeints(jvalue, shapes))) goto done;
|
||||
}
|
||||
@ -1702,7 +1702,7 @@ define_vars(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames)
|
||||
var->storage = NC_CHUNKED;
|
||||
if(var->ndims != rank)
|
||||
{stat = (THROW(NC_ENCZARR)); goto done;}
|
||||
if((var->chunksizes = malloc(sizeof(size_t)*zarr_rank)) == NULL)
|
||||
if((var->chunksizes = malloc(sizeof(size_t)*(size_t)zarr_rank)) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
if((stat = decodeints(jvalue, chunks))) goto done;
|
||||
/* validate the chunk sizes */
|
||||
|
@ -801,8 +801,8 @@ NCZ_comma_parse(const char* s, NClist* list)
|
||||
endp = strchr(p,',');
|
||||
if(endp == NULL) endp = p + strlen(p);
|
||||
slen = (endp - p);
|
||||
if((s = malloc(slen+1)) == NULL) {stat = NC_ENOMEM; goto done;}
|
||||
memcpy(s,p,slen);
|
||||
if((s = malloc((size_t)slen+1)) == NULL) {stat = NC_ENOMEM; goto done;}
|
||||
memcpy(s,p,(size_t)slen);
|
||||
s[slen] = '\0';
|
||||
if(nclistmatch(list,s,0)) {
|
||||
nullfree(s); /* duplicate */
|
||||
@ -1013,9 +1013,9 @@ NCZ_fixed2char(const void* fixed, char** charp, size_t count, int maxstrlen)
|
||||
if(p[0] == '\0') {
|
||||
sp = NULL;
|
||||
} else {
|
||||
if((sp = (unsigned char*)malloc(maxstrlen+1))==NULL) /* ensure null terminated */
|
||||
if((sp = (unsigned char*)malloc((size_t)maxstrlen+1))==NULL) /* ensure null terminated */
|
||||
return NC_ENOMEM;
|
||||
memcpy(sp,p,maxstrlen);
|
||||
memcpy(sp,p,(size_t)maxstrlen);
|
||||
sp[maxstrlen] = '\0';
|
||||
}
|
||||
charp[i] = (char*)sp;
|
||||
|
@ -239,11 +239,12 @@ give_var_secret_name(NC_VAR_INFO_T *var, const char *name)
|
||||
* clash. */
|
||||
if (strlen(name) + strlen(NON_COORD_PREPEND) > NC_MAX_NAME)
|
||||
return NC_EMAXNAME;
|
||||
if (!(var->ncz_name = malloc((strlen(NON_COORD_PREPEND) +
|
||||
strlen(name) + 1) * sizeof(char))))
|
||||
size_t ncz_name_size = (strlen(NON_COORD_PREPEND) + strlen(name) + 1) *
|
||||
sizeof(char);
|
||||
if (!(var->ncz_name = malloc(ncz_name_size)))
|
||||
return NC_ENOMEM;
|
||||
|
||||
sprintf(var->ncz_name, "%s%s", NON_COORD_PREPEND, name);
|
||||
snprintf(var->ncz_name, ncz_name_size, "%s%s", NON_COORD_PREPEND, name);
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
@ -1545,7 +1546,7 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
#endif
|
||||
size64_t fdims[NC_MAX_VAR_DIMS];
|
||||
size64_t start[NC_MAX_VAR_DIMS], count[NC_MAX_VAR_DIMS];
|
||||
size64_t stride[NC_MAX_VAR_DIMS];
|
||||
size64_t stride[NC_MAX_VAR_DIMS], ones[NC_MAX_VAR_DIMS];
|
||||
int retval, range_error = 0, i, d2;
|
||||
void *bufr = NULL;
|
||||
int bufrd = 0; /* 1 => we allocated bufr */
|
||||
@ -1590,6 +1591,7 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[0] = 0;
|
||||
count[0] = 1;
|
||||
stride[0] = 1;
|
||||
ones[0] = 1;
|
||||
} else {
|
||||
for (i = 0; i < var->ndims; i++)
|
||||
{
|
||||
@ -1601,6 +1603,7 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[i] = startp[i];
|
||||
count[i] = countp ? countp[i] : fdims[i];
|
||||
stride[i] = stridep ? stridep[i] : 1;
|
||||
ones[i] = 1;
|
||||
|
||||
/* Check to see if any counts are zero. */
|
||||
if (!count[i])
|
||||
@ -1632,6 +1635,31 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef LOOK
|
||||
/* Now you would think that no one would be crazy enough to write
|
||||
a scalar dataspace with one of the array function calls, but you
|
||||
would be wrong. So let's check to see if the dataset is
|
||||
scalar. If it is, we won't try to set up a hyperslab. */
|
||||
if (H5Sget_simple_extent_type(file_spaceid) == H5S_SCALAR)
|
||||
{
|
||||
if ((mem_spaceid = H5Screate(H5S_SCALAR)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET, start, stride,
|
||||
ones, count) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
/* Create a space for the memory, just big enough to hold the slab
|
||||
we want. */
|
||||
if ((mem_spaceid = H5Screate_simple(var->ndims, count, NULL)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Are we going to convert any data? (No converting of compound or
|
||||
* opaque or vlen types.) We also need to call this code if we are doing
|
||||
* quantization. */
|
||||
@ -1675,6 +1703,7 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
do no harm to reextend it to that size. */
|
||||
if (var->ndims)
|
||||
{
|
||||
|
||||
for (d2 = 0; d2 < var->ndims; d2++)
|
||||
{
|
||||
size64_t endindex = start[d2] + stride[d2] * (count[d2] - 1); /* last index written */
|
||||
@ -1698,6 +1727,30 @@ NCZ_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef LOOK
|
||||
/* If we need to extend it, we also need a new file_spaceid
|
||||
to reflect the new size of the space. */
|
||||
if (need_to_extend)
|
||||
{
|
||||
LOG((4, "extending dataset"));
|
||||
/* Convert xtend_size back to hsize_t for use with
|
||||
* H5Dset_extent. */
|
||||
for (d2 = 0; d2 < var->ndims; d2++)
|
||||
fdims[d2] = (size64_t)xtend_size[d2];
|
||||
if (H5Dset_extent(ncz_var->hdf_datasetid, fdims) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (file_spaceid > 0 && H5Sclose(file_spaceid) < 0)
|
||||
BAIL2(NC_EHDFERR);
|
||||
if ((file_spaceid = H5Dget_space(ncz_var->hdf_datasetid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, ones, count) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Do we need to convert the data? */
|
||||
@ -1800,8 +1853,8 @@ NCZ_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
size64_t fdims[NC_MAX_VAR_DIMS]; /* size of the dimensions */
|
||||
size64_t start[NC_MAX_VAR_DIMS];
|
||||
size64_t stride[NC_MAX_VAR_DIMS];
|
||||
int no_read = 0;
|
||||
int provide_fill = 0;
|
||||
size64_t ones[NC_MAX_VAR_DIMS];
|
||||
int no_read = 0, provide_fill = 0;
|
||||
int fill_value_size[NC_MAX_VAR_DIMS];
|
||||
int retval, range_error = 0, i, d2;
|
||||
void *bufr = NULL;
|
||||
@ -1833,6 +1886,7 @@ NCZ_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[0] = 0;
|
||||
count[0] = 1;
|
||||
stride[0] = 1;
|
||||
ones[0] = 1;
|
||||
} else {
|
||||
for (i = 0; i < var->ndims; i++)
|
||||
{
|
||||
@ -1842,6 +1896,12 @@ NCZ_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
start[i] = startp[i];
|
||||
count[i] = countp[i];
|
||||
stride[i] = stridep ? stridep[i] : 1;
|
||||
|
||||
ones[i] = 1;
|
||||
/* if any of the count values are zero don't actually read. */
|
||||
if (count[i] == 0)
|
||||
no_read++;
|
||||
|
||||
/* Get dimension sizes also */
|
||||
fdims[i] = var->dim[i]->len;
|
||||
/* if any of the counts are zero don't actually read. */
|
||||
@ -1959,7 +2019,7 @@ NCZ_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
else
|
||||
{
|
||||
if (H5Sselect_hyperslab(file_spaceid, H5S_SELECT_SET,
|
||||
start, stride, count, NULL) < 0)
|
||||
start, stride, ones, count) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
/* Create a space for the memory, just big enough to hold the slab
|
||||
we want. */
|
||||
|
@ -586,7 +586,7 @@ NCZ_projectslices(struct Common* common,
|
||||
size64_t stride[NC_MAX_VAR_DIMS];
|
||||
size64_t len[NC_MAX_VAR_DIMS];
|
||||
|
||||
if((allprojections = calloc(common->rank,sizeof(NCZSliceProjections))) == NULL)
|
||||
if((allprojections = calloc((size_t)common->rank, sizeof(NCZSliceProjections))) == NULL)
|
||||
{stat = NC_ENOMEM; goto done;}
|
||||
memset(ranges,0,sizeof(ranges));
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "zcache.h"
|
||||
#include "ncxcache.h"
|
||||
#include "zfilter.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
@ -662,7 +663,7 @@ put_chunk(NCZChunkCache* cache, NCZCacheEntry* entry)
|
||||
/* Convert from char* to char[strlen] format */
|
||||
int maxstrlen = NCZ_get_maxstrlen((NC_OBJ*)cache->var);
|
||||
assert(maxstrlen > 0);
|
||||
if((strchunk = malloc(cache->chunkcount*maxstrlen))==NULL) {stat = NC_ENOMEM; goto done;}
|
||||
if((strchunk = malloc((size_t)cache->chunkcount * (size_t)maxstrlen))==NULL) {stat = NC_ENOMEM; goto done;}
|
||||
/* copy char* to char[] format */
|
||||
if((stat = NCZ_char2fixed((const char**)entry->data,strchunk,cache->chunkcount,maxstrlen))) goto done;
|
||||
/* Reclaim the old chunk */
|
||||
|
@ -604,7 +604,7 @@ ncio_ffio_assign(const char *filename) {
|
||||
errno=E2BIG;
|
||||
return (const char *) NULL;
|
||||
}
|
||||
(void) sprintf(buffer,"-F %s %s", envstr,xtra_assign);
|
||||
(void) snprintf(buffer,sizeof(buffer),"-F %s %s", envstr,xtra_assign);
|
||||
#ifdef __crayx1
|
||||
ASNFILE(filename, buffer, &istat, strlen(filename)+1, strlen(buffer)+1);
|
||||
#else
|
||||
|
@ -39,7 +39,7 @@ ifdef(`PNETCDF',`
|
||||
`#'if HAVE_CONFIG_H
|
||||
`#'include <config.h>
|
||||
`#'endif')
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -763,27 +763,27 @@ int main () {
|
||||
uintmax_t umax = UINTMAX_C(0);
|
||||
char str0[256], str1[256];
|
||||
|
||||
sprintf (str0, "%d %x\n", 0, ~0);
|
||||
snprintf (str0, sizeof(str0), "%d %x\n", 0, ~0);
|
||||
|
||||
sprintf (str1, "%d %x\n", i8, ~0);
|
||||
snprintf (str1, sizeof(str1), "%d %x\n", i8, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
|
||||
sprintf (str1, "%u %x\n", u8, ~0);
|
||||
snprintf (str1, sizeof(str1), "%u %x\n", u8, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
|
||||
sprintf (str1, "%d %x\n", i16, ~0);
|
||||
snprintf (str1, sizeof(str1), "%d %x\n", i16, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
|
||||
sprintf (str1, "%u %x\n", u16, ~0);
|
||||
snprintf (str1, sizeof(str1), "%u %x\n", u16, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
|
||||
sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
|
||||
snprintf (str1, sizeof(str1), "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
|
||||
sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
|
||||
snprintf (str1, sizeof(str1), "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
|
||||
#ifdef INT64_MAX
|
||||
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
|
||||
snprintf (str1, sizeof(str1), "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
|
||||
#endif
|
||||
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
|
||||
snprintf (str1, sizeof(str1), "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
|
||||
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
|
||||
snprintf (str1, sizeof(str1), "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
|
||||
if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
|
||||
|
||||
TESTUMAX(8);
|
||||
|
@ -1254,7 +1254,7 @@ NC_computeshapes(NC3_INFO* ncp)
|
||||
for( /*NADA*/; vpp < end; vpp++)
|
||||
{
|
||||
status = NC_var_shape(*vpp, &ncp->dims);
|
||||
if(status != NC_NOERR)
|
||||
if(status != NC_NOERR)
|
||||
return(status);
|
||||
|
||||
if(IS_RECVAR(*vpp))
|
||||
@ -1265,13 +1265,13 @@ NC_computeshapes(NC3_INFO* ncp)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(first_var == NULL)
|
||||
if(first_var == NULL)
|
||||
first_var = *vpp;
|
||||
/*
|
||||
* Overwritten each time thru.
|
||||
* Usually overwritten in first_rec != NULL clause below.
|
||||
*/
|
||||
ncp->begin_rec = (*vpp)->begin + (off_t)(*vpp)->len;
|
||||
/*
|
||||
* Overwritten each time thru.
|
||||
* Usually overwritten in first_rec != NULL clause below.
|
||||
*/
|
||||
ncp->begin_rec = (*vpp)->begin + (off_t)(*vpp)->len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ nc4_get_att_ptrs(NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var,
|
||||
!(mem_type == NC_CHAR &&
|
||||
(att->nc_typeid == NC_UBYTE || att->nc_typeid == NC_BYTE)))
|
||||
{
|
||||
if (!(bufr = malloc((size_t)(att->len * type_size))))
|
||||
if (!(bufr = malloc((size_t)(att->len) * type_size)))
|
||||
BAIL(NC_ENOMEM);
|
||||
need_to_convert++;
|
||||
if ((retval = nc4_convert_type(att->data, bufr, att->nc_typeid,
|
||||
|
@ -177,9 +177,9 @@ NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
|
||||
;
|
||||
|
||||
/* Allocate storage. */
|
||||
if (!(name = malloc((g + 1) * (NC_MAX_NAME + 1) + 1)))
|
||||
if (!(name = malloc((size_t)(g + 1) * (NC_MAX_NAME + 1) + 1)))
|
||||
return NC_ENOMEM;
|
||||
if (!(gid = malloc((g + 1) * sizeof(int))))
|
||||
if (!(gid = malloc((size_t)(g + 1) * sizeof(int))))
|
||||
{
|
||||
free(name);
|
||||
return NC_ENOMEM;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ncdispatch.h" /* from libdispatch */
|
||||
#include "ncutf8.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include "ncrc.h"
|
||||
|
||||
/** @internal Number of reserved attributes. These attributes are
|
||||
@ -788,14 +789,14 @@ nc4_var_set_ndims(NC_VAR_INFO_T *var, int ndims)
|
||||
/* Allocate space for dimension information. */
|
||||
if (ndims)
|
||||
{
|
||||
if (!(var->dim = calloc(ndims, sizeof(NC_DIM_INFO_T *))))
|
||||
if (!(var->dim = calloc((size_t)ndims, sizeof(NC_DIM_INFO_T *))))
|
||||
return NC_ENOMEM;
|
||||
if (!(var->dimids = calloc(ndims, sizeof(int))))
|
||||
if (!(var->dimids = calloc((size_t)ndims, sizeof(int))))
|
||||
return NC_ENOMEM;
|
||||
|
||||
/* Initialize dimids to illegal values (-1). See the comment
|
||||
in nc4_rec_match_dimscales(). */
|
||||
memset(var->dimids, -1, ndims * sizeof(int));
|
||||
memset(var->dimids, -1, (size_t)ndims * sizeof(int));
|
||||
}
|
||||
|
||||
return NC_NOERR;
|
||||
@ -1159,7 +1160,7 @@ nc4_field_list_add(NC_TYPE_INFO_T *parent, const char *name,
|
||||
if (ndims)
|
||||
{
|
||||
int i;
|
||||
if (!(field->dim_size = malloc(ndims * sizeof(int))))
|
||||
if (!(field->dim_size = malloc((size_t)ndims * sizeof(int))))
|
||||
{
|
||||
free(field->hdr.name);
|
||||
free(field);
|
||||
@ -1742,7 +1743,7 @@ nc4_init_logging(void)
|
||||
}
|
||||
|
||||
/* Create a filename with the rank in it. */
|
||||
sprintf(log_filename, "nc4_log_%d.log", my_rank);
|
||||
snprintf(log_filename, sizeof(log_filename), "nc4_log_%d.log", my_rank);
|
||||
|
||||
/* Open a file for this rank to log messages. */
|
||||
if (!(LOG_FILE = fopen(log_filename, "w")))
|
||||
@ -1875,7 +1876,7 @@ rec_print_metadata(NC_GRP_INFO_T *grp, int tab_count)
|
||||
strcpy(dims_string, "");
|
||||
for (d = 0; d < var->ndims; d++)
|
||||
{
|
||||
sprintf(temp_string, " %d", var->dimids[d]);
|
||||
snprintf(temp_string, sizeof(temp_string), " %d", var->dimids[d]);
|
||||
strcat(dims_string, temp_string);
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ fi
|
||||
|
||||
has_multifilters="yes"
|
||||
|
||||
has_zstd="@HAS_ZSTD"
|
||||
has_zstd="@HAVE_ZSTD@"
|
||||
if [ -z "$has_zstd" -o "$has_zstd" = "OFF" -o "$has_zstd" = "FALSE" ]; then
|
||||
has_zstd="no"
|
||||
else
|
||||
|
@ -462,7 +462,7 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
|
||||
size_t *data_read_us, int *data_write_us, int *in_format, int use_par,
|
||||
int par_access, float *num_bytes, int p, int my_rank,
|
||||
int slow_count, int verbose, int use_scs, int endianness,
|
||||
int convert_unlim)
|
||||
int convert_unlim, int zstandard, int nsd)
|
||||
{
|
||||
int ncid_in, ncid_out;
|
||||
int natts, nvars, ndims, unlimdimid;
|
||||
@ -578,6 +578,9 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
|
||||
/* Create the output var. */
|
||||
if (nc_def_var(ncid_out, name, xtype, ndims, dimids, &varid_out)) ERR;
|
||||
|
||||
if (nsd)
|
||||
if (nc_def_var_quantize(ncid_out, varid_out, NC_QUANTIZE_GRANULARBR, nsd)) ERR;
|
||||
|
||||
/* Set the output endianness. For simplicity in this program,
|
||||
* all vars get the same endianness. But there's no reason why
|
||||
* this couldn't be varied from var to var, though it is hard to
|
||||
@ -598,7 +601,20 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
|
||||
if (nc_def_var_chunking(ncid_out, v, 1, NULL)) ERR;
|
||||
}
|
||||
if (vo[o1].deflate_num != -1)
|
||||
if (nc_def_var_deflate(ncid_out, v, vo[o1].shuffle, 1, vo[o1].deflate_num)) ERR;
|
||||
{
|
||||
if (zstandard)
|
||||
{
|
||||
int ret;
|
||||
if (nc_def_var_deflate(ncid_out, v, vo[o1].shuffle, 0, 0)) ERR;
|
||||
if ((ret = nc_def_var_zstandard(ncid_out, v, vo[o1].deflate_num)))
|
||||
{
|
||||
printf("ret %d\n", ret);
|
||||
ERR;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (nc_def_var_deflate(ncid_out, v, vo[o1].shuffle, 1, vo[o1].deflate_num)) ERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -780,7 +796,6 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
|
||||
|
||||
#define NDIMS 3
|
||||
#define MAX_DEFLATE 9
|
||||
#define INPUT_FILE "/upc/share/testdata/nssl/mosaic3d_nc/tile1/20070803-2300.netcdf"
|
||||
#define COLON ":"
|
||||
#define COMMA ","
|
||||
|
||||
@ -800,13 +815,15 @@ int copy_file(char *file_name_in, char *file_name_out, int cmode_out,
|
||||
[-i] Use MPIIO (only relevant for parallel builds).\n\
|
||||
[-l] Convert unlimited dimensions to fixed dimensions.\n\
|
||||
[-e 1|2] Set the endianness of output (1=little 2=big).\n\
|
||||
[-y] Use zstandard compression instead of zlib.\n\
|
||||
[-q nsd] Quantize to NSD.\n\
|
||||
file Name of netCDF file\n"
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "bm_file -v [-s N]|[-t V:S:S:S -u V:C:C:C -r V:I:I:I] -o file_out -f N -h"
|
||||
" -c V:C:C,V:C:C:C -d -m -p -i -e 1|2 -l file\n%s", USAGE);
|
||||
" -c V:C:C,V:C:C:C -d -m -p -i -e 1|2 -l -y -q N file\n%s", USAGE);
|
||||
}
|
||||
|
||||
int
|
||||
@ -819,6 +836,7 @@ main(int argc, char **argv)
|
||||
char file_in[NC_MAX_NAME + 1], file_out[NC_MAX_NAME + 1] = {""};
|
||||
char file_out_2[NC_MAX_NAME + 10 + 1]; /* extra 10 to silence warning */
|
||||
int out_format, in_format, header = 0, doublecheck = 0;
|
||||
int zstandard = 0;
|
||||
int convert_unlim = 0;
|
||||
char *str1, *str2, *token, *subtoken;
|
||||
char *saveptr1, *saveptr2;
|
||||
@ -839,6 +857,7 @@ main(int argc, char **argv)
|
||||
float read_rate, write_rate, reread_rate;
|
||||
int slow_count = 10, use_scs = 0;
|
||||
int endianness = 0;
|
||||
int nsd = 0;
|
||||
float num_bytes = 0;
|
||||
int p = 1, my_rank = 0;
|
||||
int c;
|
||||
@ -857,7 +876,7 @@ main(int argc, char **argv)
|
||||
for (i = 0; i < MAX_DIMS; i++)
|
||||
vo[o1].chunksize[i] = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "vo:f:hc:dpms:it:u:r:e:l")) != EOF)
|
||||
while ((c = getopt(argc, argv, "vo:f:hc:dpms:it:u:r:e:l:yq:")) != EOF)
|
||||
switch(c)
|
||||
{
|
||||
case 'v':
|
||||
@ -1000,6 +1019,12 @@ main(int argc, char **argv)
|
||||
case 'l':
|
||||
convert_unlim++;
|
||||
break;
|
||||
case 'y':
|
||||
zstandard++;
|
||||
break;
|
||||
case 'q':
|
||||
sscanf(optarg, "%d", &nsd);
|
||||
break;
|
||||
case '?':
|
||||
usage();
|
||||
return 1;
|
||||
@ -1060,7 +1085,7 @@ main(int argc, char **argv)
|
||||
if ((ret = copy_file(file_in, file_out, cmode, num_vo, vo, &meta_read_us, &meta_write_us,
|
||||
&data_read_us, &data_write_us, &in_format, use_par, par_access,
|
||||
&num_bytes, p, my_rank, slow_count, verbose, use_scs, endianness,
|
||||
convert_unlim)))
|
||||
convert_unlim, zstandard, nsd)))
|
||||
return ret;
|
||||
|
||||
/* If the user wants a double check, make sure the data in the new
|
||||
@ -1075,8 +1100,8 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
/* Create a copy of file_out. This will defeat any buffering
|
||||
* that may exist from the fact that we just wrote file_out. */
|
||||
sprintf(file_out_2, "tst_copy_%s", file_out);
|
||||
sprintf(cmd, "cp %s %s\n", file_out, file_out_2);
|
||||
snprintf(file_out_2, sizeof(file_out_2), "tst_copy_%s", file_out);
|
||||
snprintf(cmd, sizeof(cmd), "cp %s %s\n", file_out, file_out_2);
|
||||
system(cmd);
|
||||
|
||||
if ((ret = cmp_file(file_in, file_out_2, &meta_read2_us, &data_read2_us,
|
||||
@ -1133,7 +1158,7 @@ main(int argc, char **argv)
|
||||
if (use_par)
|
||||
printf("num_proc, ");
|
||||
printf("deflate, shuffle, chunksize[0], chunksize[1], chunksize[2], "
|
||||
"chunksize[3]\n");
|
||||
"chunksize[3], zstandard, nsd\n");
|
||||
}
|
||||
|
||||
printf("%d, %d, %ld, %ld, %d, %d, %ld, %d, %d, ", in_format, out_format, file_size(file_in),
|
||||
@ -1148,8 +1173,8 @@ main(int argc, char **argv)
|
||||
printf("%d, ", p);
|
||||
for (o1 = 0; o1 < num_vo; o1++)
|
||||
{
|
||||
printf("%d, %d, %d, %d, %d, %d ", vo[o1].deflate_num, vo[o1].shuffle,
|
||||
(int)vo[o1].chunksize[0], (int)vo[o1].chunksize[1], (int)vo[o1].chunksize[2], (int)vo[o1].chunksize[3]);
|
||||
printf("%d, %d, %d, %d, %d, %d, %d, %d", vo[o1].deflate_num, vo[o1].shuffle,
|
||||
(int)vo[o1].chunksize[0], (int)vo[o1].chunksize[1], (int)vo[o1].chunksize[2], (int)vo[o1].chunksize[3], zstandard, nsd);
|
||||
if (o1 >= MAX_VO_PRINTED)
|
||||
break;
|
||||
if (o1 != num_vo - 1)
|
||||
|
@ -58,12 +58,12 @@ int main(int argc, char **argv)
|
||||
ERR;
|
||||
|
||||
for(g = 1; g < numgrp + 1; g++) {
|
||||
sprintf(gname, "group%d", g);
|
||||
snprintf(gname, sizeof(gname), "group%d", g);
|
||||
if (nc_def_grp(ncid, gname, &grp)) ERR;
|
||||
natts = g < numgrp ? NC_MAX_ATTRS : aleft; /* leftovers on last time through */
|
||||
for(an = 1; an < natts + 1; an++) {
|
||||
char aname[20];
|
||||
sprintf(aname, "attribute%d", a);
|
||||
snprintf(aname, sizeof(aname), "attribute%d", a);
|
||||
if (nc_put_att_int(grp, NC_GLOBAL, aname, NC_INT, 1, data)) ERR;
|
||||
if(a%100 == 0) { /* only print every 100th attribute name */
|
||||
if (gettimeofday(&end_time, NULL)) ERR;
|
||||
|
@ -52,7 +52,7 @@ int main(int argc, char **argv)
|
||||
/* create N groups, printing time after every 1000 */
|
||||
numgrp = nitem;
|
||||
for(g = 1; g < numgrp + 1; g++) {
|
||||
sprintf(gname, "group%d", g);
|
||||
snprintf(gname, sizeof(gname), "group%d", g);
|
||||
if (nc_def_grp(ncid, gname, &grp)) ERR;
|
||||
if (nc_def_var(grp, "var", NC_INT, 0, NULL, &var)) ERR;
|
||||
if(nc_enddef (grp)) ERR;
|
||||
@ -80,13 +80,13 @@ int main(int argc, char **argv)
|
||||
ERR;
|
||||
|
||||
for(g = 1; g < numgrp + 1; g++) {
|
||||
sprintf(gname, "group%d", g);
|
||||
snprintf(gname, sizeof(gname), "group%d", g);
|
||||
if (nc_def_grp(ncid, gname, &grp)) ERR;
|
||||
nvars = g < numgrp ? NC_MAX_VARS : vleft; /* leftovers on last time through */
|
||||
for(vn = 1; vn < nvars + 1; vn++) {
|
||||
int var;
|
||||
char vname[20];
|
||||
sprintf(vname, "variable%d", v);
|
||||
snprintf(vname, sizeof(vname), "variable%d", v);
|
||||
if(nc_def_var(grp, vname, NC_INT, 0, NULL, &var)) ERR;
|
||||
if(nc_put_var(grp, var, data)) ERR;
|
||||
if(v%1000 == 0) { /* only print every 1000th variable name */
|
||||
|
@ -150,8 +150,7 @@ variables:
|
||||
RESULT. Return 1 if the difference is negative, otherwise 0. This
|
||||
function from the GNU documentation. */
|
||||
static int
|
||||
timeval_subtract (result, x, y)
|
||||
struct timeval *result, *x, *y;
|
||||
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y)
|
||||
{
|
||||
/* Perform the carry for the later subtraction by updating Y. */
|
||||
if (x->tv_usec < y->tv_usec) {
|
||||
|
@ -48,7 +48,7 @@ add_attributes(int ncid, int varid, size_t num_atts, size_t att_len)
|
||||
/* Write a bunch of attributes. */
|
||||
for (a = 0; a < num_atts; a++)
|
||||
{
|
||||
sprintf(att_name, "%s_varid_%d_att_%d", TEST, varid, a);
|
||||
snprintf(att_name, sizeof(att_name), "%s_varid_%d_att_%d", TEST, varid, a);
|
||||
if (nc_put_att_double(ncid, varid, att_name, NC_DOUBLE,
|
||||
att_len, att_data)) ERR;
|
||||
}
|
||||
@ -73,7 +73,7 @@ buildfile(size_t num_vars, size_t num_atts, size_t att_len, char *file_name)
|
||||
for (v = 0; v < num_vars; v++)
|
||||
{
|
||||
char var_name[NC_MAX_NAME + 1];
|
||||
sprintf(var_name, "%s_var_%d", TEST, v);
|
||||
snprintf(var_name, sizeof(var_name), "%s_var_%d", TEST, v);
|
||||
if (nc_def_var(ncid, var_name, NC_INT, NDIMS, dimids, &varid)) ERR;
|
||||
if (add_attributes(ncid, v, num_atts, att_len)) ERR;
|
||||
}
|
||||
@ -200,7 +200,7 @@ main(int argc, char **argv)
|
||||
long long hdf5_open_time = 0;
|
||||
|
||||
/* Determine file name. */
|
||||
sprintf(file_name, "%s_%d_%d.nc", TEST, num_vars, r);
|
||||
snprintf(file_name, sizeof(file_name), "%s_%d_%d.nc", TEST, num_vars, r);
|
||||
|
||||
if (buildfile(num_vars, num_atts, ATT_LEN, file_name)) ERR;
|
||||
if (readfile(file_name, &nc4_open_time, do_inq, num_vars)) ERR;
|
||||
@ -242,7 +242,7 @@ main(int argc, char **argv)
|
||||
long long hdf5_open_time;
|
||||
|
||||
/* Determine file name. */
|
||||
sprintf(file_name, "%s_%d_%d_%d.nc", TEST, num_vars, s, r);
|
||||
snprintf(file_name, sizeof(file_name), "%s_%d_%d_%d.nc", TEST, num_vars, s, r);
|
||||
|
||||
if (buildfile(num_vars, num_atts, ATT_LEN, file_name)) ERR;
|
||||
if (readfile(file_name, &nc4_open_time, do_inq, num_vars)) ERR;
|
||||
|
@ -74,7 +74,7 @@ main(int argc, char **argv)
|
||||
if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimid[2])) ERR;
|
||||
for (v = 0; v < NUM_VAR; v++)
|
||||
{
|
||||
sprintf(name, "var_%d", v);
|
||||
snprintf(name, sizeof(name), "var_%d", v);
|
||||
if (nc_def_var(ncid, name, NC_FLOAT, NDIM3, dimid, &varid[v])) ERR;
|
||||
if (nc_def_var_chunking(ncid, v, NC_CHUNKED, chunksize)) ERR;
|
||||
}
|
||||
@ -103,8 +103,8 @@ main(int argc, char **argv)
|
||||
{
|
||||
/* Create a copy of file_out. This will defeat any OS
|
||||
* buffering. */
|
||||
sprintf(file_2, "tst_copy_%d_%s", c, FILE_NAME);
|
||||
sprintf(cmd, "cp %s %s\n", FILE_NAME, file_2);
|
||||
snprintf(file_2, sizeof(file_2), "tst_copy_%d_%s", c, FILE_NAME);
|
||||
snprintf(cmd, sizeof(cmd), "cp %s %s\n", FILE_NAME, file_2);
|
||||
system(cmd);
|
||||
}
|
||||
else
|
||||
|
@ -307,7 +307,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = dims[1];
|
||||
count[2] = dims[2];
|
||||
|
||||
sprintf(time_mess," contiguous write %3d %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous write %3d %3ld %3ld",
|
||||
1, dims[1], dims[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -319,7 +319,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked write %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked write %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
1, dims[1], dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -335,7 +335,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed write %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed write %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
1, dims[1], dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -360,7 +360,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = 1;
|
||||
count[2] = dims[2];
|
||||
|
||||
sprintf(time_mess," contiguous write %3ld %3d %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous write %3ld %3d %3ld",
|
||||
dims[0], 1, dims[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -372,7 +372,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked write %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked write %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
dims[0], 1, dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -388,7 +388,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed write %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed write %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
dims[0], 1, dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -413,7 +413,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = dims[1];
|
||||
count[2] = 1;
|
||||
|
||||
sprintf(time_mess," contiguous write %3ld %3ld %3d",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous write %3ld %3ld %3d",
|
||||
dims[0], dims[1], 1);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
@ -425,7 +425,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked write %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked write %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
dims[0], dims[1], 1, chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
@ -441,7 +441,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed write %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed write %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
dims[0], dims[1], 1, chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
@ -466,7 +466,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = dims[1];
|
||||
count[2] = dims[2];
|
||||
|
||||
sprintf(time_mess," contiguous read %3d %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous read %3d %3ld %3ld",
|
||||
1, dims[1], dims[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -478,7 +478,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked read %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked read %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
1, dims[1], dims[2] , chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -494,7 +494,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed read %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed read %3d %3ld %3ld %3ld %3ld %3ld",
|
||||
1, dims[1], dims[2] , chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[0]; i++) {
|
||||
@ -519,7 +519,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = 1;
|
||||
count[2] = dims[2];
|
||||
|
||||
sprintf(time_mess," contiguous read %3ld %3d %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous read %3ld %3d %3ld",
|
||||
dims[0], 1, dims[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -531,7 +531,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked read %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked read %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
dims[0], 1, dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -547,7 +547,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed read %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed read %3ld %3d %3ld %3ld %3ld %3ld",
|
||||
dims[0], 1, dims[2], chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[1]; i++) {
|
||||
@ -572,7 +572,7 @@ main(int argc, char *argv[]) {
|
||||
count[1] = dims[1];
|
||||
count[2] = 1;
|
||||
|
||||
sprintf(time_mess," contiguous read %3ld %3ld %3d",
|
||||
snprintf(time_mess, sizeof(time_mess)," contiguous read %3ld %3ld %3d",
|
||||
dims[0], dims[1], 1);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
@ -584,7 +584,7 @@ main(int argc, char *argv[]) {
|
||||
printf("\n");
|
||||
contig_time = TMsec;
|
||||
|
||||
sprintf(time_mess," chunked read %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," chunked read %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
dims[0], dims[1], 1, chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
@ -600,7 +600,7 @@ main(int argc, char *argv[]) {
|
||||
else
|
||||
printf(" %5.2g x slower\n", 1.0/ratio);
|
||||
|
||||
sprintf(time_mess," compressed read %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
snprintf(time_mess, sizeof(time_mess)," compressed read %3ld %3ld %3d %3ld %3ld %3ld",
|
||||
dims[0], dims[1], 1, chunks[0], chunks[1], chunks[2]);
|
||||
TIMING_START ;
|
||||
for(i = 0; i < dims[2]; i++) {
|
||||
|
@ -282,7 +282,7 @@ write_meta(int ncid, int *data_varid, int s, int f, int nsd, int deflate, int u,
|
||||
{
|
||||
char data_var_name[NC_MAX_NAME + 1];
|
||||
|
||||
sprintf(data_var_name, "var_%d", dv);
|
||||
snprintf(data_var_name, sizeof(data_var_name), "var_%d", dv);
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (nc_def_var(ncid, data_var_name, NC_FLOAT, NDIM4, dimid_data, &data_varid[dv])) ERR;
|
||||
|
||||
@ -567,7 +567,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Use the same filename every time, so we don't
|
||||
* create many large files, just one. ;-) */
|
||||
sprintf(file_name, "%s.nc", TEST_NAME);
|
||||
snprintf(file_name, sizeof(file_name), "%s.nc", TEST_NAME);
|
||||
|
||||
/* Remove the last file. Ignore errors. */
|
||||
remove(file_name);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user