Merged https://github.com/Unidata/netcdf-c/pull/319 to resolve some recently arisen conflicts, in preparation for larger merge.

This commit is contained in:
Ward Fisher 2017-02-01 13:27:29 -07:00
commit 3e5124996e
41 changed files with 9723 additions and 6999 deletions

2
.gitignore vendored
View File

@ -10,6 +10,8 @@ ctest.c
ctest64.c
nc_test/test_get.c
nc_test/test_put.c
nc_test/test_read.c
nc_test/test_write.c
#####
# End ignored generated files.

View File

@ -970,14 +970,14 @@ IF(ENABLE_PNETCDF)
FIND_LIBRARY(PNETCDF NAMES pnetcdf)
FIND_PATH(PNETCDF_INCLUDE_DIR pnetcdf.h)
IF(NOT PNETCDF)
MESSAGE(STATUS "Cannot find PNetCDF library. Disabling PNetCDF support.")
MESSAGE(STATUS "Cannot find PnetCDF library. Disabling PnetCDF support.")
SET(USE_PNETCDF OFF CACHE BOOL "")
ELSE(NOT PNETCDF)
SET(USE_PARALLEL ON CACHE BOOL "")
# Check PNetCDF version. Must be >= 1.6.0
# Check PnetCDF version. Must be >= 1.6.0
set(pnetcdf_h "${PNETCDF_INCLUDE_DIR}/pnetcdf.h" )
message(STATUS "PNetCDF include file ${pnetcdf_h} will be searched for version")
message(STATUS "PnetCDF include file ${pnetcdf_h} will be searched for version")
file(STRINGS "${pnetcdf_h}" pnetcdf_major_string REGEX "^#define PNETCDF_VERSION_MAJOR")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_major "${pnetcdf_major_string}")
file(STRINGS "${pnetcdf_h}" pnetcdf_minor_string REGEX "^#define PNETCDF_VERSION_MINOR")
@ -985,7 +985,7 @@ IF(ENABLE_PNETCDF)
file(STRINGS "${pnetcdf_h}" pnetcdf_sub_string REGEX "^#define PNETCDF_VERSION_SUB")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_sub "${pnetcdf_sub_string}")
set(pnetcdf_version "${pnetcdf_major}.${pnetcdf_minor}.${pnetcdf_sub}")
message(STATUS "Found PNetCDF version ${pnetcdf_version}")
message(STATUS "Found PnetCDF version ${pnetcdf_version}")
if(${pnetcdf_version} VERSION_GREATER "1.6.0")
SET(STATUS_PNETCDF "ON")
@ -994,13 +994,66 @@ IF(ENABLE_PNETCDF)
# pnetcdf => parallel
SET(STATUS_PARALLEL ON)
SET(USE_PARALLEL ON)
MESSAGE(STATUS "Using PNetCDF Library: ${PNETCDF}")
MESSAGE(STATUS "Using PnetCDF Library: ${PNETCDF}")
ELSE()
MESSAGE(WARNING "ENABLE_PNETCDF requires version 1.6.1 or later; found version ${pnetcdf_version}. PNetCDF is disabled")
MESSAGE(WARNING "ENABLE_PNETCDF requires version 1.6.1 or later; found version ${pnetcdf_version}. PnetCDF is disabled")
ENDIF()
ENDIF(NOT PNETCDF)
ENDIF()
# Options to enable use of fill values for elements casuing NC_ERANGE
SET(STATUS_ERANGE_FILL "ON")
OPTION(ENABLE_ERANGE_FILL "Enable use of fill value when out-of-range type conversion causes NC_ERANGE error." ON)
IF(NOT ENABLE_ERANGE_FILL)
SET(STATUS_ERANGE_FILL "OFF")
ENDIF()
# Options to use a more relaxed coordinate argument boundary check
SET(STATUS_RELAX_COORD_BOUND "OFF")
OPTION(ENABLE_RELAX_COORD_BOUND "Enable a more relaxed boundary error check NC_EINVALCOORDS to allow coordinate start argument equal to dimension size when argument count is zero." OFF)
IF(ENABLE_RELAX_COORD_BOUND)
SET(STATUS_RELAX_COORD_BOUND "ON")
ENDIF()
# check and conform with PnetCDF settings on ERANGE_FILL and RELAX_COORD_BOUND
IF(STATUS_PNETCDF)
file(STRINGS "${pnetcdf_h}" enable_erange_fill_pnetcdf REGEX "^#define PNETCDF_ERANGE_FILL")
string(REGEX REPLACE "[^0-9]" "" erange_fill_pnetcdf "${enable_erange_fill_pnetcdf}")
IF("x${erange_fill_pnetcdf}" STREQUAL "x1")
IF(NOT STATUS_ERANGE_FILL)
MESSAGE(WARNING "Enable erange-fill to conform with PnetCDF setting")
SET(STATUS_ERANGE_FILL "ON")
ENDIF()
ELSE()
IF(STATUS_ERANGE_FILL)
MESSAGE(WARNING "Disable erange-fill to conform with PnetCDF setting")
SET(STATUS_ERANGE_FILL "OFF")
ENDIF()
ENDIF()
file(STRINGS "${pnetcdf_h}" relax_coord_bound_pnetcdf REGEX "^#define PNETCDF_RELAX_COORD_BOUND")
string(REGEX REPLACE "[^0-9]" "" relax_coord_bound "${relax_coord_bound_pnetcdf}")
IF("x${relax_coord_bound}" STREQUAL "x1")
IF(NOT STATUS_RELAX_COORD_BOUND)
MESSAGE(WARNING "Enable relax-coord-bound to conform with PnetCDF setting")
SET(STATUS_RELAX_COORD_BOUND "ON")
ENDIF()
ELSE()
IF(STATUS_RELAX_COORD_BOUND)
MESSAGE(WARNING "Disable relax-coord-bound to conform with PnetCDF setting")
SET(STATUS_RELAX_COORD_BOUND "OFF")
ENDIF()
ENDIF()
ENDIF()
IF(STATUS_ERANGE_FILL)
SET(M4FLAGS "-DERANGE_FILL" CACHE STRING "")
ENDIF()
IF(STATUS_RELAX_COORD_BOUND)
MESSAGE(STATUS "Enabling a more relatexed check for NC_EINVALCOORDS")
ADD_DEFINITIONS(-DRELAX_COORD_BOUND)
ENDIF()
# Enable Parallel Tests.
OPTION(ENABLE_PARALLEL_TESTS "Enable Parallel IO Tests. Ignored if netCDF4 is not enabled, or if there is no parallel I/O Support." ${USE_PARALLEL})
IF(ENABLE_PARALLEL_TESTS AND USE_PARALLEL)
@ -1228,9 +1281,13 @@ ENDIF(SIZEOF_PTRDIFF_T)
# __int64 is used on Windows for large file support.
CHECK_TYPE_SIZE("__int64" SIZEOF___INT_64)
CHECK_TYPE_SIZE("uchar" SIZEOF_UCHAR)
CHECK_TYPE_SIZE("int64_t" SIZEOF_INT64_T)
CHECK_TYPE_SIZE("uint64_t" SIZEOF_UINT64_T)
CHECK_TYPE_SIZE("unsigned char" SIZEOF_UCHAR)
CHECK_TYPE_SIZE("unsigned short int" SIZEOF_USHORT)
CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
CHECK_TYPE_SIZE("long long" SIZEOF_LONGLONG)
CHECK_TYPE_SIZE("unsigned long long" SIZEOF_ULONGLONG)
# On windows systems, we redefine off_t as __int64
# to enable LFS. This is true on 32 and 64 bit system.s
@ -1324,7 +1381,7 @@ IF(HAVE_M4)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
COMMAND ${NC_M4}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
ARGS ${M4FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.m4 > ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.c
VERBATIM
)
ENDIF(HAVE_M4)
@ -1792,6 +1849,7 @@ is_enabled(USE_DAP HAS_DAP)
is_enabled(USE_DISKLESS HAS_DISKLESS)
is_enabled(USE_MMAP HAS_MMAP)
is_enabled(JNA HAS_JNA)
is_enabled(STATUS_RELAX_COORD_BOUND RELAX_COORD_BOUND)
# Generate file from template.
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/libnetcdf.settings.in"

View File

@ -128,6 +128,7 @@ settings_DATA=libnetcdf.settings
####
MM4= ./nc_test/test_put ./nc_test/test_get \
./nc_test/test_write ./nc_test/test_read \
./libsrc/netcdf ./libsrc/putget ./libsrc/ncx \
./libsrc/t_ncxx ./libsrc/attr

View File

@ -749,3 +749,25 @@ esac
])# AX_C_FLOAT_WORDS_BIGENDIAN
dnl Find the full path of a header file
dnl
dnl UD_CHECK_HEADER_PATH(file, [action-if-found], [action-if-not-found])
dnl Example:
dnl UD_CHECK_HEADER_PATH([math.h])
dnl AC_MSG_NOTICE([ac_cv_header_path_math_h=$ac_cv_header_path_math_h])
dnl
dnl
AC_DEFUN([UD_CHECK_HEADER_PATH],
[
AS_VAR_PUSHDEF([ac_Path], [ac_cv_header_path_$1])dnl
AC_CACHE_CHECK(
[for full path of header file $1], [ac_Path],
[AC_PREPROC_IFELSE(
[AC_LANG_PROGRAM([[#include <$1>]])],
[AS_VAR_SET([ac_Path], [`sed -n '/\.h"/s/.*"\(.*\)".*/\1/p' conftest.i | grep -m 1 $1`])],
[AC_MSG_RESULT([not found])]
)])
AS_VAR_SET_IF([ac_Path], [$2], [$3])
AS_VAR_POPDEF([ac_Path])dnl
])

View File

@ -45,7 +45,9 @@ are set when opening a binary file on Windows. */
#define fdopen _fdopen
#define write _write
#define strtoll _strtoi64
#endif
#endif /*_MSC_VER */
#cmakedefine const
/* Define if building universal (internal helper macro) */
#cmakedefine AC_APPLE_UNIVERSAL_BUILD 1
@ -447,6 +449,27 @@ are set when opening a binary file on Windows. */
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION "${netCDF_VERSION}"
/* The size of `ulonglong` as computed by sizeof. */
#cmakedefine SIZEOF_ULONGLONG @SIZEOF_ULONGLONG@
/* The size of `longlong` as computed by sizeof. */
#cmakedefine SIZEOF_LONGLONG @SIZEOF_LONGLONG@
/* The size of `uchar` as computed by sizeof. */
#cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@
/* The size of `ssize_t` as computed by sizeof. */
#cmakedefine SIZEOF_SSIZE_T @SIZEOF_SSIZE_T@
/* The size of `__int64` found on Windows systems. */
#cmakedefine SIZEOF___INT64 ${SIZEOF___INT64}
/* The size of `void*` as computed by sizeof. */
#cmakedefine SIZEOF_VOIDSTAR ${SIZEOF_VOIDSTAR}
/* The size of `short` as computed by sizeof. */
#cmakedefine SIZEOF_OFF64_T ${SIZEOF_OFF64_T}
4
/* The size of `double', as computed by sizeof. */
#cmakedefine SIZEOF_DOUBLE ${SIZEOF_DOUBLE}
@ -598,6 +621,40 @@ are set when opening a binary file on Windows. */
/* Define to empty if `const' does not conform to ANSI C. */
#cmakedefine const
#cmakedefine TEMP_LARGE "@TEMP_LARGE@"
/* Set if we have strdup */
#cmakedefine HAVE_STRDUP
#cmakedefine HAVE_STRNDUP
#cmakedefine HAVE_STRLCAT
#cmakedefine HAVE_STRERROR
#cmakedefine HAVE_SNPRINTF
#cmakedefine HAVE_STRCHR
#cmakedefine HAVE_STRRCHR
#cmakedefine HAVE_STRCAT
#cmakedefine HAVE_STRCPY
#cmakedefine HAVE_STRDUP
#cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRTOD
#cmakedefine HAVE_STRTOLL
#cmakedefine HAVE_STROULL
#cmakedefine HAVE_STRSTR
#cmakedefine HAVE_MKSTEMP
#cmakedefine HAVE_RAND
#cmakedefine HAVE_RANDOM
#cmakedefine HAVE_GETTIMEOFDAY
#cmakedefine HAVE_MPI_COMM_F2C
#cmakedefine HAVE_MEMMOVE
#cmakedefine HAVE_MMAP
#cmakedefine HAVE_GETPAGESIZE
#cmakedefine HAVE_SYSCONF
#cmakedefine HAVE_MREMAP
#cmakedefine HAVE_DECL_ISINF
#cmakedefine HAVE_GETRLIMIT
#cmakedefine HAVE_FSYNC
>>>>>>> fe9685deb4bed403f26b530d7f89c25d781719db
/* Define to `long int' if <sys/types.h> does not define. */
#cmakedefine off_t long int

View File

@ -858,6 +858,13 @@ AC_CHECK_SIZEOF(size_t)
$SLEEPCMD
AC_CHECK_SIZEOF(unsigned long long)
$SLEEPCMD
if test "$ac_cv_type_uchar" = yes ; then
AC_CHECK_SIZEOF(uchar)
else
AC_CHECK_SIZEOF(unsigned char)
fi
$SLEEPCMD
if test "$ac_cv_type_ushort" = yes ; then
AC_CHECK_SIZEOF(ushort)
@ -1079,6 +1086,83 @@ if test "x$enable_parallel" = xyes; then
AC_DEFINE([USE_PARALLEL], [1], [if true, pnetcdf or parallel netcdf-4 is in use])
fi
AC_ARG_ENABLE([erange_fill],
[AS_HELP_STRING([--disable-erange-fill],
[Disable use of fill value when out-of-range type
conversion causes NC_ERANGE error. @<:@default: enabled@:>@])],
[enable_erange_fill=${enableval}], [enable_erange_fill=yes]
)
AC_ARG_ENABLE([relax-coord-bound],
[AS_HELP_STRING([--enable-relax-coord-bound],
[Enable a more relaxed boundary error check NC_EINVALCOORDS
to allow coordinate start argument equal to dimension size
when argument count is zero. @<:@default: disabled@:>@])],
[enable_relax_coord_bound=${enableval}], [enable_relax_coord_bound=no]
)
# check PnetCDF's settings on enable_erange_fill and relax_coord_bound
if test "x$enable_pnetcdf" = xyes; then
UD_CHECK_HEADER_PATH([pnetcdf.h])
AC_MSG_CHECKING([if erange-fill is enabled in PnetCDF])
erange_fill_pnetcdf=`grep PNETCDF_ERANGE_FILL ${ac_cv_header_path_pnetcdf_h}`
if test "x$erange_fill_pnetcdf" = x; then
erange_fill_pnetcdf=no
else
erange_fill_pnetcdf=`echo ${erange_fill_pnetcdf} | cut -d' ' -f3`
if test "x$coord_bound_pnetcdf" = x0; then
enable_erange_fill_pnetcdf=no
else
enable_erange_fill_pnetcdf=yes
fi
fi
AC_MSG_NOTICE([$enable_erange_fill_pnetcdf])
if test "$enable_erange_fill" != "$enable_erange_fill_pnetcdf"; then
if test "$enable_erange_fill_pnetcdf" = yes; then
AC_MSG_WARN([Enable erange-fill to conform with PnetCDF setting])
else
AC_MSG_WARN([Disable erange-fill to conform with PnetCDF setting])
fi
enable_erange_fill=$enable_erange_fill_pnetcdf
fi
AC_MSG_CHECKING([if relax-coord-bound is enabled in PnetCDF])
relax_coord_bound_pnetcdf=`grep PNETCDF_RELAX_COORD_BOUND ${ac_cv_header_path_pnetcdf_h}`
if test "x$relax_coord_bound_pnetcdf" = x; then
relax_coord_bound_pnetcdf=no
else
coord_bound_pnetcdf=`echo ${relax_coord_bound_pnetcdf} | cut -d' ' -f3`
if test "x$coord_bound_pnetcdf" = x0; then
relax_coord_bound_pnetcdf=no
else
relax_coord_bound_pnetcdf=yes
fi
fi
AC_MSG_NOTICE([$relax_coord_bound_pnetcdf])
if test "$enable_relax_coord_bound" != "$relax_coord_bound_pnetcdf"; then
if test "$relax_coord_bound_pnetcdf" = yes; then
AC_MSG_WARN([Enable relax-coord-bound to conform with PnetCDF setting])
else
AC_MSG_WARN([Disable relax-coord-bound to conform with PnetCDF setting])
fi
enable_relax_coord_bound=$relax_coord_bound_pnetcdf
fi
fi
if test "x$enable_erange_fill" = xyes ; then
if test "x$M4FLAGS" = x ; then
M4FLAGS="-DERANGE_FILL"
else
M4FLAGS="$M4FLAGS -DERANGE_FILL"
fi
fi
AC_SUBST(M4FLAGS)
if test "x$enable_relax_coord_bound" = xyes; then
AC_DEFINE([RELAX_COORD_BOUND], [1], [if true, NC_EINVALCOORDS check is more relaxed])
fi
# Check for downloading/building fortran via postinstall script.
if test "x$enable_remote_fortran_bootstrap" = xyes; then
AC_DEFINE([BUILD_FORTRAN], 1, [If true, will attempt to download and build netcdf-fortran.])
@ -1246,6 +1330,7 @@ AC_SUBST(HAS_PARALLEL4,[$enable_parallel4])
AC_SUBST(HAS_DISKLESS,[$enable_diskless])
AC_SUBST(HAS_MMAP,[$enable_mmap])
AC_SUBST(HAS_JNA,[$enable_jna])
AC_SUBST(RELAX_COORD_BOUND,[$enable_relax_coord_bound])
# Include some specifics for netcdf on windows.
#AH_VERBATIM([_WIN32_STRICMP],

View File

@ -38,11 +38,7 @@ typedef struct NC {
typedef struct {
/* all xdr'd */
size_t nchars;
#ifdef __arm__
signed char *cp;
#else
char *cp;
#endif
} NC_string;
@ -55,17 +51,10 @@ free_NC_string(NC_string *ncstrp);
extern int
NC_check_name(const char *name);
#ifdef __arm__
extern NC_string *
new_NC_string(size_t slen, const signed char *str);
extern int
set_NC_string(NC_string *ncstrp, const signed char *str);
#else
extern NC_string *
new_NC_string(size_t slen, const char *str);
extern int
set_NC_string(NC_string *ncstrp, const char *str);
#endif
/* End defined in string.c */

View File

@ -389,6 +389,12 @@ NC_sync(NC3_INFO* ncp);
extern int
NC_calcsize(const NC3_INFO* ncp, off_t *filesizep);
extern int
NC3_inq_default_fill_value(int xtype, void *fillp);
extern int
NC3_inq_var_fill(const NC_var *varp, void *fill_value);
/* End defined in nc.c */
/* Begin defined in v1hpg.c */

View File

@ -228,13 +228,8 @@ fail:
NC_new_string(count, str)
*/
#ifdef __arm__
NC_string *
new_NC_string(size_t slen, const signed char *str)
#else
NC_string *
new_NC_string(size_t slen, const char *str)
#endif
{
NC_string *ncstrp;
size_t sz = M_RNDUP(sizeof(NC_string)) + slen + 1;
@ -269,13 +264,8 @@ new_NC_string(size_t slen, const char *str)
NC_re_string()
*/
#ifdef __arm__
int
set_NC_string(NC_string *ncstrp, const signed char *str)
#else
int
set_NC_string(NC_string *ncstrp, const char *str)
#endif
{
size_t slen;

View File

@ -143,6 +143,7 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
NC* ncp;
int memtypelen;
size_t vartypelen;
size_t nels;
char* value = (char*)value0;
size_t numrecs;
size_t varshape[NC_MAX_VAR_DIMS];
@ -200,9 +201,18 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
/* Do various checks and fixups on start/edges/stride */
simplestride = 1; /* assume so */
nels = 1;
for(i=0;i<rank;i++) {
size_t dimlen;
mystart[i] = (start == NULL ? 0 : start[i]);
/* illegal value checks */
dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
/* mystart is unsigned, never < 0 */
#ifdef RELAX_COORD_BOUND
if (mystart[i] > dimlen) return NC_EINVALCOORDS;
#else
if (mystart[i] >= dimlen) return NC_EINVALCOORDS;
#endif
if(edges == NULL) {
if(i == 0 && isrecvar)
myedges[i] = numrecs - start[i];
@ -210,23 +220,23 @@ NCDEFAULT_get_vars(int ncid, int varid, const size_t * start,
myedges[i] = varshape[i] - mystart[i];
} else
myedges[i] = edges[i];
if(myedges[i] == 0)
return NC_NOERR; /* cannot read anything */
#ifdef RELAX_COORD_BOUND
if (mystart[i] == dimlen && myedges[i] > 0) return NC_EINVALCOORDS;
#endif
/* myedges is unsigned, never < 0 */
if(mystart[i] + myedges[i] > dimlen)
return NC_EEDGE;
mystride[i] = (stride == NULL ? 1 : stride[i]);
if(mystride[i] <= 0
/* cast needed for braindead systems with signed size_t */
|| ((unsigned long) mystride[i] >= X_INT_MAX))
return NC_ESTRIDE;
if(mystride[i] != 1) simplestride = 0;
/* illegal value checks */
dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
/* mystart is unsigned, never < 0 */
if(mystart[i] >= dimlen)
return NC_EINVALCOORDS;
/* myedges is unsigned, never < 0 */
if(mystart[i] + myedges[i] > dimlen)
return NC_EEDGE;
if(myedges[i] == 0)
nels = 0;
}
if(nels == 0)
return NC_NOERR; /* cannot read anything */
if(simplestride) {
return NC_get_vara(ncid, varid, mystart, myedges, value, memtype);
}
@ -376,17 +386,26 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
mymap = mystride + varndims;
/*
* Initialize I/O parameters.
* Check start, edges
*/
for (idim = maxidim; idim >= 0; --idim)
{
size_t dimlen =
idim == 0 && isrecvar
? numrecs
: varshape[idim];
mystart[idim] = start != NULL
? start[idim]
: 0;
if (edges != NULL && edges[idim] == 0)
#ifdef RELAX_COORD_BOUND
if (mystart[idim] > dimlen)
#else
if (mystart[idim] >= dimlen)
#endif
{
status = NC_NOERR; /* read/write no data */
status = NC_EINVALCOORDS;
goto done;
}
@ -405,6 +424,33 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
myedges[idim] = varshape[idim] - mystart[idim];
#endif
#ifdef RELAX_COORD_BOUND
if (mystart[idim] == dimlen && myedges[idim] > 0)
{
status = NC_EINVALCOORDS;
goto done;
}
#endif
if (mystart[idim] + myedges[idim] > dimlen)
{
status = NC_EEDGE;
goto done;
}
}
/*
* Initialize I/O parameters.
*/
for (idim = maxidim; idim >= 0; --idim)
{
if (edges != NULL && edges[idim] == 0)
{
status = NC_NOERR; /* read/write no data */
goto done;
}
mystride[idim] = stride != NULL
? stride[idim]
: 1;
@ -430,30 +476,6 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
stop[idim] = (mystart[idim] + myedges[idim] * (size_t)mystride[idim]);
}
/*
* Check start, edges
*/
for (idim = maxidim; idim >= 0; --idim)
{
size_t dimlen =
idim == 0 && isrecvar
? numrecs
: varshape[idim];
if (mystart[idim] >= dimlen)
{
status = NC_EINVALCOORDS;
goto done;
}
if (mystart[idim] + myedges[idim] > dimlen)
{
status = NC_EEDGE;
goto done;
}
}
/* Lower body */
/*
* As an optimization, adjust I/O parameters when the fastest

View File

@ -128,6 +128,7 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
nc_type vartype = NC_NAT;
NC* ncp;
size_t vartypelen;
size_t nels;
int memtypelen;
const char* value = (const char*)value0;
size_t numrecs;
@ -193,9 +194,26 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
/* Do various checks and fixups on start/edges/stride */
isstride1 = 1; /* assume so */
nels = 1;
for(i=0;i<rank;i++) {
size_t dimlen;
mystart[i] = (start == NULL ? 0 : start[i]);
#if 0
dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
if(i == 0 && isrecvar) {/*do nothing*/}
#else
/* illegal value checks */
dimlen = varshape[i];
if(is_recdim[i]) {/*do nothing*/}
#endif
else {
/* mystart is unsigned, will never be < 0 */
#ifdef RELAX_COORD_BOUND
if (mystart[i] > dimlen) return NC_EINVALCOORDS;
#else
if (mystart[i] >= dimlen) return NC_EINVALCOORDS;
#endif
}
if(edges == NULL) {
#if 0
if(i == 0 && isrecvar)
@ -208,31 +226,27 @@ NCDEFAULT_put_vars(int ncid, int varid, const size_t * start,
myedges[i] = varshape[i] - mystart[i];
} else
myedges[i] = edges[i];
if(myedges[i] == 0)
return NC_NOERR; /* cannot write anything */
#ifdef RELAX_COORD_BOUND
if(!is_recdim[i]) {
if (mystart[i] == dimlen && myedges[i] > 0)
return NC_EINVALCOORDS;
}
#endif
if(!is_recdim[i]) {
/* myediges is unsigned, will never be < 0 */
if(mystart[i] + myedges[i] > dimlen)
return NC_EEDGE;
}
mystride[i] = (stride == NULL ? 1 : stride[i]);
if(mystride[i] <= 0
/* cast needed for braindead systems with signed size_t */
|| ((unsigned long) mystride[i] >= X_INT_MAX))
return NC_ESTRIDE;
if(mystride[i] != 1) isstride1 = 0;
/* illegal value checks */
#if 0
dimlen = (i == 0 && isrecvar ? numrecs : varshape[i]);
if(i == 0 && isrecvar) {/*do nothing*/}
#else
dimlen = varshape[i];
if(is_recdim[i]) {/*do nothing*/}
#endif
else {
/* mystart is unsigned, will never be < 0 */
if(mystart[i] > dimlen)
return NC_EINVALCOORDS;
/* myediges is unsigned, will never be < 0 */
if(mystart[i] + myedges[i] > dimlen)
return NC_EEDGE;
}
nels *= myedges[i];
}
if(nels == 0)
return NC_NOERR; /* cannot write anything */
if(isstride1) {
return NC_put_vara(ncid, varid, mystart, myedges, value, memtype);
}
@ -384,7 +398,7 @@ NCDEFAULT_put_varm(
mymap = mystride + varndims;
/*
* Initialize I/O parameters.
* Check start, edges
*/
for (idim = maxidim; idim >= 0; --idim)
{
@ -392,17 +406,44 @@ NCDEFAULT_put_varm(
? start[idim]
: 0;
myedges[idim] = edges != NULL
? edges[idim]
: idim == 0 && isrecvar
? numrecs - mystart[idim]
: varshape[idim] - mystart[idim];
}
for (idim = isrecvar; idim <= maxidim; ++idim)
{
#ifdef RELAX_COORD_BOUND
if (mystart[idim] > varshape[idim] ||
(mystart[idim] == varshape[idim] && myedges[idim] > 0))
#else
if (mystart[idim] >= varshape[idim])
#endif
{
status = NC_EINVALCOORDS;
goto done;
}
if (mystart[idim] + myedges[idim] > varshape[idim])
{
status = NC_EEDGE;
goto done;
}
}
/*
* Initialize I/O parameters.
*/
for (idim = maxidim; idim >= 0; --idim)
{
if (edges != NULL && edges[idim] == 0)
{
status = NC_NOERR; /* read/write no data */
goto done;
}
myedges[idim] = edges != NULL
? edges[idim]
: idim == 0 && isrecvar
? numrecs - mystart[idim]
: varshape[idim] - mystart[idim];
mystride[idim] = stride != NULL
? stride[idim]
: 1;
@ -417,23 +458,6 @@ NCDEFAULT_put_varm(
stop[idim] = mystart[idim] + myedges[idim] * (size_t)mystride[idim];
}
/*
* Check start, edges
*/
for (idim = isrecvar; idim < maxidim; ++idim)
{
if (mystart[idim] > varshape[idim])
{
status = NC_EINVALCOORDS;
goto done;
}
if (mystart[idim] + myedges[idim] > varshape[idim])
{
status = NC_EEDGE;
goto done;
}
}
/* Lower body */
/*
* As an optimization, adjust I/O parameters when the fastest

View File

@ -28,7 +28,7 @@ NetCDF-2 API: @HAS_NC2@
HDF4 Support: @HAS_HDF4@
NetCDF-4 API: @HAS_NC4@
NC-4 Parallel Support: @HAS_PARALLEL4@
PNetCDF Support: @HAS_PNETCDF@
PnetCDF Support: @HAS_PNETCDF@
DAP Support: @HAS_DAP@
Diskless Support: @HAS_DISKLESS@
MMap Support: @HAS_MMAP@

View File

@ -396,6 +396,9 @@ NC_lookupattr(int ncid,
if(ncap == NULL)
return NC_ENOTVAR;
if(name == NULL)
return NC_EBADNAME;
tmp = NC_findattr(ncap, name);
if(tmp == NULL)
return NC_ENOTATT;
@ -631,31 +634,31 @@ dnl
define(`XNCX_PAD_PUTN',dnl
`dnl
static int
ncx_pad_putn_I$1(void **xpp, size_t nelems, const $1 *tp, nc_type type)
ncx_pad_putn_I$1(void **xpp, size_t nelems, const $1 *tp, nc_type type, void *fillp)
{
switch(type) {
case NC_CHAR:
return NC_ECHAR;
case NC_BYTE:
return ncx_pad_putn_schar_$1(xpp, nelems, tp);
return ncx_pad_putn_schar_$1(xpp, nelems, tp, fillp);
case NC_SHORT:
return ncx_pad_putn_short_$1(xpp, nelems, tp);
return ncx_pad_putn_short_$1(xpp, nelems, tp, fillp);
case NC_INT:
return ncx_putn_int_$1(xpp, nelems, tp);
return ncx_putn_int_$1(xpp, nelems, tp, fillp);
case NC_FLOAT:
return ncx_putn_float_$1(xpp, nelems, tp);
return ncx_putn_float_$1(xpp, nelems, tp, fillp);
case NC_DOUBLE:
return ncx_putn_double_$1(xpp, nelems, tp);
return ncx_putn_double_$1(xpp, nelems, tp, fillp);
case NC_UBYTE:
return ncx_pad_putn_uchar_$1(xpp, nelems, tp);
return ncx_pad_putn_uchar_$1(xpp, nelems, tp, fillp);
case NC_USHORT:
return ncx_putn_ushort_$1(xpp, nelems, tp);
return ncx_putn_ushort_$1(xpp, nelems, tp, fillp);
case NC_UINT:
return ncx_putn_uint_$1(xpp, nelems, tp);
return ncx_putn_uint_$1(xpp, nelems, tp, fillp);
case NC_INT64:
return ncx_putn_longlong_$1(xpp, nelems, tp);
return ncx_putn_longlong_$1(xpp, nelems, tp, fillp);
case NC_UINT64:
return ncx_putn_ulonglong_$1(xpp, nelems, tp);
return ncx_putn_ulonglong_$1(xpp, nelems, tp, fillp);
default:
assert("ncx_pad_putn_I$1 invalid type" == 0);
}
@ -740,31 +743,31 @@ XNCX_PAD_GETN(ulonglong)
/* Common dispatcher for put cases */
static int
dispatchput(void **xpp, size_t nelems, const void* tp,
nc_type atype, nc_type memtype)
nc_type atype, nc_type memtype, void *fillp)
{
switch (memtype) {
case NC_CHAR:
return ncx_pad_putn_text(xpp,nelems, (char *)tp);
case NC_BYTE:
return ncx_pad_putn_Ischar(xpp, nelems, (schar*)tp, atype);
return ncx_pad_putn_Ischar(xpp, nelems, (schar*)tp, atype, fillp);
case NC_SHORT:
return ncx_pad_putn_Ishort(xpp, nelems, (short*)tp, atype);
return ncx_pad_putn_Ishort(xpp, nelems, (short*)tp, atype, fillp);
case NC_INT:
return ncx_pad_putn_Iint(xpp, nelems, (int*)tp, atype);
return ncx_pad_putn_Iint(xpp, nelems, (int*)tp, atype, fillp);
case NC_FLOAT:
return ncx_pad_putn_Ifloat(xpp, nelems, (float*)tp, atype);
return ncx_pad_putn_Ifloat(xpp, nelems, (float*)tp, atype, fillp);
case NC_DOUBLE:
return ncx_pad_putn_Idouble(xpp, nelems, (double*)tp, atype);
return ncx_pad_putn_Idouble(xpp, nelems, (double*)tp, atype, fillp);
case NC_UBYTE: /*Synthetic*/
return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype);
return ncx_pad_putn_Iuchar(xpp,nelems, (uchar *)tp, atype, fillp);
case NC_INT64:
return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype);
return ncx_pad_putn_Ilonglong(xpp, nelems, (longlong*)tp, atype, fillp);
case NC_USHORT:
return ncx_pad_putn_Iushort(xpp, nelems, (ushort*)tp, atype);
return ncx_pad_putn_Iushort(xpp, nelems, (ushort*)tp, atype, fillp);
case NC_UINT:
return ncx_pad_putn_Iuint(xpp, nelems, (uint*)tp, atype);
return ncx_pad_putn_Iuint(xpp, nelems, (uint*)tp, atype, fillp);
case NC_UINT64:
return ncx_pad_putn_Iulonglong(xpp, nelems, (ulonglong*)tp, atype);
return ncx_pad_putn_Iulonglong(xpp, nelems, (ulonglong*)tp, atype, fillp);
case NC_NAT:
return NC_EBADTYPE;
default:
@ -790,6 +793,7 @@ NC3_put_att(
NC_attr **attrpp;
NC_attr *old = NULL;
NC_attr *attrp;
unsigned char fill[8]; /* fill value in internal representation */
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
@ -803,6 +807,10 @@ NC3_put_att(
if(ncap == NULL)
return NC_ENOTVAR;
if (name == NULL)
return NC_EBADNAME;
/* check NC_EBADTYPE */
status = nc3_cktype(nc->mode, type);
if(status != NC_NOERR)
return status;
@ -825,6 +833,9 @@ NC3_put_att(
/* 4 cases: exists X indef */
status = NC3_inq_default_fill_value(type, &fill);
if (status != NC_NOERR) return status;
if(attrpp != NULL) { /* name in use */
if(!NC_indef(ncp)) {
const size_t xsz = ncx_len_NC_attrV(type, nelems);
@ -839,7 +850,13 @@ NC3_put_att(
if(nelems != 0) {
void *xp = attrp->xvalue;
status = dispatchput(&xp, nelems, (const void*)value, type, memtype);
/* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
if (!fIsSet(ncp->flags,NC_64BIT_DATA) && type == NC_BYTE && memtype == NC_UBYTE) {
status = NC3_inq_default_fill_value(NC_UBYTE, &fill);
if (status != NC_NOERR) return status;
status = dispatchput(&xp, nelems, value, memtype, memtype, &fill);
} else
status = dispatchput(&xp, nelems, value, type, memtype, &fill);
}
set_NC_hdirty(ncp);
@ -871,7 +888,13 @@ NC3_put_att(
if(nelems != 0) {
void *xp = attrp->xvalue;
status = dispatchput(&xp, nelems, (const void*)value, type, memtype);
/* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
if (!fIsSet(ncp->flags,NC_64BIT_DATA) && type == NC_BYTE && memtype == NC_UBYTE) {
status = NC3_inq_default_fill_value(NC_UBYTE, &fill);
if (status != NC_NOERR) return status;
status = dispatchput(&xp, nelems, value, memtype, memtype, &fill);
} else
status = dispatchput(&xp, nelems, value, type, memtype, &fill);
}
if(attrpp != NULL) {
@ -901,9 +924,16 @@ NC3_get_att(
nc_type memtype)
{
int status;
NC *nc;
NC3_INFO* ncp;
NC_attr *attrp;
const void *xp;
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR)
return status;
ncp = NC3_DATA(nc);
status = NC_lookupattr(ncid, varid, name, &attrp);
if(status != NC_NOERR) return status;
@ -919,7 +949,7 @@ NC3_get_att(
xp = attrp->xvalue;
switch (memtype) {
case NC_CHAR:
return ncx_pad_getn_text(&xp, attrp->nelems , (char *)value);
return ncx_pad_getn_text(&xp, attrp->nelems, (char *)value);
case NC_BYTE:
return ncx_pad_getn_Ischar(&xp,attrp->nelems,(schar*)value,attrp->type);
case NC_SHORT:
@ -933,14 +963,17 @@ NC3_get_att(
case NC_INT64:
return ncx_pad_getn_Ilonglong(&xp,attrp->nelems,(longlong*)value,attrp->type);
case NC_UBYTE: /* Synthetic */
return ncx_pad_getn_Iuchar(&xp, attrp->nelems , (uchar *)value, attrp->type);
/* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
if (!fIsSet(ncp->flags,NC_64BIT_DATA) && attrp->type == NC_BYTE)
return ncx_pad_getn_Iuchar(&xp, attrp->nelems, (uchar *)value, NC_UBYTE);
else
return ncx_pad_getn_Iuchar(&xp, attrp->nelems, (uchar *)value, attrp->type);
case NC_USHORT:
return ncx_pad_getn_Iushort(&xp,attrp->nelems,(ushort*)value,attrp->type);
case NC_UINT:
return ncx_pad_getn_Iuint(&xp,attrp->nelems,(uint*)value,attrp->type);
case NC_UINT64:
return ncx_pad_getn_Iulonglong(&xp,attrp->nelems,(ulonglong*)value,attrp->type);
case NC_NAT:
return NC_EBADTYPE;
default:
@ -949,3 +982,4 @@ NC3_get_att(
status = NC_EBADTYPE;
return status;
}

View File

@ -351,9 +351,9 @@ read_numrecs(NC3_INFO *ncp)
return status;
if (fIsSet(ncp->flags, NC_64BIT_DATA)) {
long long tmp=0;
status = ncx_get_int64(&xp, &tmp);
new_nrecs = tmp;
unsigned long long tmp=0;
status = ncx_get_uint64(&xp, &tmp);
new_nrecs = (size_t)tmp;
} else
status = ncx_get_size_t(&xp, &new_nrecs);
@ -394,7 +394,7 @@ write_numrecs(NC3_INFO *ncp)
{
const size_t nrecs = NC_get_numrecs(ncp);
if (fIsSet(ncp->flags, NC_64BIT_DATA))
status = ncx_put_int64(&xp, nrecs);
status = ncx_put_uint64(&xp, (unsigned long long)nrecs);
else
status = ncx_put_size_t(&xp, &nrecs);
}
@ -1724,3 +1724,80 @@ nc_delete(const char * path)
{
return nc_delete_mp(path, 0);
}
/*----< NC3_inq_default_fill_value() >---------------------------------------*/
/* copy the default fill value to the memory space pointed by fillp */
int
NC3_inq_default_fill_value(int xtype, void *fillp)
{
if (fillp == NULL) return NC_NOERR;
switch(xtype) {
case NC_CHAR : *(char*)fillp = NC_FILL_CHAR; break;
case NC_BYTE : *(signed char*)fillp = NC_FILL_BYTE; break;
case NC_SHORT : *(short*)fillp = NC_FILL_SHORT; break;
case NC_INT : *(int*)fillp = NC_FILL_INT; break;
case NC_FLOAT : *(float*)fillp = NC_FILL_FLOAT; break;
case NC_DOUBLE : *(double*)fillp = NC_FILL_DOUBLE; break;
case NC_UBYTE : *(unsigned char*)fillp = NC_FILL_UBYTE; break;
case NC_USHORT : *(unsigned short*)fillp = NC_FILL_USHORT; break;
case NC_UINT : *(unsigned int*)fillp = NC_FILL_UINT; break;
case NC_INT64 : *(long long*)fillp = NC_FILL_INT64; break;
case NC_UINT64 : *(unsigned long long*)fillp = NC_FILL_UINT64; break;
default : return NC_EBADTYPE;
}
return NC_NOERR;
}
/*----< NC3_inq_var_fill() >-------------------------------------------------*/
/* inquire the fill value of a variable */
int
NC3_inq_var_fill(const NC_var *varp, void *fill_value)
{
NC_attr **attrpp = NULL;
if (fill_value == NULL) return NC_EINVAL;
/*
* find fill value
*/
attrpp = NC_findattr(&varp->attrs, _FillValue);
if ( attrpp != NULL ) {
/* User defined fill value */
if ( (*attrpp)->type != varp->type || (*attrpp)->nelems != 1 )
return NC_EBADTYPE;
else
(void) memcpy(fill_value, (*attrpp)->xvalue, varp->xsz);
}
else {
/* use the default */
switch(varp->type){
case NC_CHAR: *(char *)fill_value = NC_FILL_CHAR;
break;
case NC_BYTE: *(signed char *)fill_value = NC_FILL_BYTE;
break;
case NC_SHORT: *(short *)fill_value = NC_FILL_SHORT;
break;
case NC_INT: *(int *)fill_value = NC_FILL_INT;
break;
case NC_UBYTE: *(unsigned char *)fill_value = NC_FILL_UBYTE;
break;
case NC_USHORT: *(unsigned short *)fill_value = NC_FILL_USHORT;
break;
case NC_UINT: *(unsigned int *)fill_value = NC_FILL_UINT;
break;
case NC_INT64: *(long long *)fill_value = NC_FILL_INT64;
break;
case NC_UINT64: *(unsigned long long *)fill_value = NC_FILL_UINT64;
break;
case NC_FLOAT: *(float *)fill_value = NC_FILL_FLOAT;
break;
case NC_DOUBLE: *(double *)fill_value = NC_FILL_DOUBLE;
break;
default:
return NC_EINVAL;
}
}
return NC_NOERR;
}

View File

@ -231,19 +231,19 @@ extern int
ncx_get_schar_double(const void *xp, double *ip);
extern int
ncx_put_schar_schar(void *xp, const schar *ip);
ncx_put_schar_schar(void *xp, const schar *ip, void *fillp);
extern int
ncx_put_schar_uchar(void *xp, const uchar *ip);
ncx_put_schar_uchar(void *xp, const uchar *ip, void *fillp);
extern int
ncx_put_schar_short(void *xp, const short *ip);
ncx_put_schar_short(void *xp, const short *ip, void *fillp);
extern int
ncx_put_schar_int(void *xp, const int *ip);
ncx_put_schar_int(void *xp, const int *ip, void *fillp);
extern int
ncx_put_schar_long(void *xp, const long *ip);
ncx_put_schar_long(void *xp, const long *ip, void *fillp);
extern int
ncx_put_schar_float(void *xp, const float *ip);
ncx_put_schar_float(void *xp, const float *ip, void *fillp);
extern int
ncx_put_schar_double(void *xp, const double *ip);
ncx_put_schar_double(void *xp, const double *ip, void *fillp);
#endif
/*
@ -275,8 +275,17 @@ ncx_put_int32(void **xpp, const int ip);
extern int
ncx_put_int64(void **xpp, const long long ip);
extern int
ncx_get_uint32(const void **xpp, unsigned int *ip);
extern int
ncx_get_uint64(const void **xpp, unsigned long long *ip);
extern int
ncx_put_uint32(void **xpp, const unsigned int ip);
extern int
ncx_put_uint64(void **xpp, const unsigned long long ip);
extern int ncx_get_int_int(const void *xp, int *ip);
extern int ncx_put_int_int(void *xp, const int *ip);
extern int ncx_put_int_int(void *xp, const int *ip, void *fillp);
/*
* Aggregate numeric conversion functions.
@ -366,50 +375,50 @@ extern int
ncx_pad_getn_schar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_schar_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_schar_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_schar_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_schar_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_schar_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_schar_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_schar_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_schar_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_schar_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_schar_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_schar_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_schar_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_schar_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_schar_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_schar_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_schar_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_schar_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_schar_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
extern int
ncx_pad_putn_schar_schar (void **xpp, size_t nelems, const schar *ip);
ncx_pad_putn_schar_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_pad_putn_schar_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_pad_putn_schar_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_pad_putn_schar_short (void **xpp, size_t nelems, const short *ip);
ncx_pad_putn_schar_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_pad_putn_schar_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_pad_putn_schar_int (void **xpp, size_t nelems, const int *ip);
ncx_pad_putn_schar_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_pad_putn_schar_uint (void **xpp, size_t nelems, const uint *ip);
ncx_pad_putn_schar_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_pad_putn_schar_long (void **xpp, size_t nelems, const long *ip);
ncx_pad_putn_schar_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_pad_putn_schar_float (void **xpp, size_t nelems, const float *ip);
ncx_pad_putn_schar_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *ip);
ncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_pad_putn_schar_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_pad_putn_schar_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_pad_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- uchar ----------------------------------------------------------------*/
extern int
@ -459,50 +468,50 @@ extern int
ncx_pad_getn_uchar_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_uchar_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_uchar_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_uchar_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_uchar_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_uchar_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_uchar_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_uchar_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_uchar_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_uchar_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_uchar_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_uchar_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_uchar_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_uchar_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_uchar_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_uchar_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_uchar_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_uchar_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_uchar_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
extern int
ncx_pad_putn_uchar_schar (void **xpp, size_t nelems, const schar *ip);
ncx_pad_putn_uchar_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_pad_putn_uchar_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_pad_putn_uchar_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_pad_putn_uchar_short (void **xpp, size_t nelems, const short *ip);
ncx_pad_putn_uchar_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_pad_putn_uchar_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_pad_putn_uchar_int (void **xpp, size_t nelems, const int *ip);
ncx_pad_putn_uchar_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_pad_putn_uchar_uint (void **xpp, size_t nelems, const uint *ip);
ncx_pad_putn_uchar_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_pad_putn_uchar_long (void **xpp, size_t nelems, const long *ip);
ncx_pad_putn_uchar_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_pad_putn_uchar_float (void **xpp, size_t nelems, const float *ip);
ncx_pad_putn_uchar_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *ip);
ncx_pad_putn_uchar_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_pad_putn_uchar_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_pad_putn_uchar_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_pad_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- short ----------------------------------------------------------------*/
extern int
@ -552,50 +561,50 @@ extern int
ncx_pad_getn_short_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_short_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_short_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_short_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_short_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_short_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_short_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_short_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_short_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_short_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_short_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_short_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_short_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_short_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_short_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_short_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_short_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_short_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_short_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
extern int
ncx_pad_putn_short_schar (void **xpp, size_t nelems, const schar *ip);
ncx_pad_putn_short_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_pad_putn_short_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_pad_putn_short_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_pad_putn_short_short (void **xpp, size_t nelems, const short *ip);
ncx_pad_putn_short_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_pad_putn_short_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_pad_putn_short_int (void **xpp, size_t nelems, const int *ip);
ncx_pad_putn_short_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_pad_putn_short_uint (void **xpp, size_t nelems, const uint *ip);
ncx_pad_putn_short_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_pad_putn_short_long (void **xpp, size_t nelems, const long *ip);
ncx_pad_putn_short_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_pad_putn_short_float (void **xpp, size_t nelems, const float *ip);
ncx_pad_putn_short_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *ip);
ncx_pad_putn_short_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_pad_putn_short_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_pad_putn_short_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_pad_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- ushort ---------------------------------------------------------------*/
extern int
@ -645,50 +654,50 @@ extern int
ncx_pad_getn_ushort_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_ushort_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_ushort_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_ushort_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_ushort_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_ushort_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_ushort_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_ushort_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_ushort_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_ushort_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_ushort_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_ushort_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_ushort_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_ushort_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_ushort_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_ushort_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_ushort_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_ushort_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_ushort_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
extern int
ncx_pad_putn_ushort_schar (void **xpp, size_t nelems, const schar *ip);
ncx_pad_putn_ushort_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_pad_putn_ushort_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_pad_putn_ushort_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_pad_putn_ushort_short (void **xpp, size_t nelems, const short *ip);
ncx_pad_putn_ushort_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_pad_putn_ushort_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_pad_putn_ushort_int (void **xpp, size_t nelems, const int *ip);
ncx_pad_putn_ushort_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_pad_putn_ushort_uint (void **xpp, size_t nelems, const uint *ip);
ncx_pad_putn_ushort_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_pad_putn_ushort_long (void **xpp, size_t nelems, const long *ip);
ncx_pad_putn_ushort_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_pad_putn_ushort_float (void **xpp, size_t nelems, const float *ip);
ncx_pad_putn_ushort_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *ip);
ncx_pad_putn_ushort_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_pad_putn_ushort_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_pad_putn_ushort_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_pad_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- int ------------------------------------------------------------------*/
extern int
@ -717,29 +726,29 @@ extern int
ncx_getn_int_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_int_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_int_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_int_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_int_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_int_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_int_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_int_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_int_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_int_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_int_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_int_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_int_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_int_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_long_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_long_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_int_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_int_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_int_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_int_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_int_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_int_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- uint -----------------------------------------------------------------*/
extern int
@ -768,29 +777,29 @@ extern int
ncx_getn_uint_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_uint_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_uint_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_uint_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_uint_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_uint_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_uint_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_uint_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_uint_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_uint_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_uint_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_uint_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_uint_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_uint_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_long_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_long_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_uint_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_uint_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_uint_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_uint_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_uint_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_uint_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- float ----------------------------------------------------------------*/
extern int
@ -817,27 +826,27 @@ extern int
ncx_getn_float_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_float_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_float_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_float_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_float_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_float_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_float_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_float_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_float_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_float_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_float_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_float_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_float_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_float_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_float_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_float_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_float_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_float_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_float_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_float_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- double ---------------------------------------------------------------*/
extern int
@ -864,27 +873,27 @@ extern int
ncx_getn_double_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_double_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_double_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_double_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_double_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_double_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_double_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_double_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_double_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_double_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_double_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_double_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_double_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_double_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_double_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_double_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_double_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_double_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_double_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_double_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_double_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- longlong ----------------------------------------------------------------*/
extern int
@ -911,27 +920,27 @@ extern int
ncx_getn_longlong_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_longlong_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_longlong_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_longlong_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_longlong_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_longlong_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_longlong_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_longlong_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_longlong_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_longlong_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_longlong_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_longlong_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_longlong_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_longlong_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_longlong_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_longlong_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_longlong_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_longlong_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_longlong_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_longlong_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_longlong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*---- ulonglong ---------------------------------------------------------------*/
extern int
@ -958,27 +967,27 @@ extern int
ncx_getn_ulonglong_ulonglong(const void **xpp, size_t nelems, ulonglong *ip);
extern int
ncx_putn_ulonglong_schar (void **xpp, size_t nelems, const schar *ip);
ncx_putn_ulonglong_schar (void **xpp, size_t nelems, const schar *ip, void *fillp);
extern int
ncx_putn_ulonglong_uchar (void **xpp, size_t nelems, const uchar *ip);
ncx_putn_ulonglong_uchar (void **xpp, size_t nelems, const uchar *ip, void *fillp);
extern int
ncx_putn_ulonglong_short (void **xpp, size_t nelems, const short *ip);
ncx_putn_ulonglong_short (void **xpp, size_t nelems, const short *ip, void *fillp);
extern int
ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *ip);
ncx_putn_ulonglong_ushort(void **xpp, size_t nelems, const ushort *ip, void *fillp);
extern int
ncx_putn_ulonglong_int (void **xpp, size_t nelems, const int *ip);
ncx_putn_ulonglong_int (void **xpp, size_t nelems, const int *ip, void *fillp);
extern int
ncx_putn_ulonglong_uint (void **xpp, size_t nelems, const uint *ip);
ncx_putn_ulonglong_uint (void **xpp, size_t nelems, const uint *ip, void *fillp);
extern int
ncx_putn_ulonglong_long (void **xpp, size_t nelems, const long *ip);
ncx_putn_ulonglong_long (void **xpp, size_t nelems, const long *ip, void *fillp);
extern int
ncx_putn_ulonglong_float (void **xpp, size_t nelems, const float *ip);
ncx_putn_ulonglong_float (void **xpp, size_t nelems, const float *ip, void *fillp);
extern int
ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *ip);
ncx_putn_ulonglong_double(void **xpp, size_t nelems, const double *ip, void *fillp);
extern int
ncx_putn_ulonglong_longlong (void **xpp, size_t nelems, const longlong *ip);
ncx_putn_ulonglong_longlong (void **xpp, size_t nelems, const longlong *ip, void *fillp);
extern int
ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip, void *fillp);
/*
@ -986,21 +995,6 @@ ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
*/
/* read ASCII characters */
#ifdef __arm__
extern int
ncx_getn_text(const void **xpp, size_t nchars, signed char *cp);
extern int
ncx_pad_getn_text(const void **xpp, size_t nchars, signed char *cp);
/* write ASCII characters */
extern int
ncx_putn_text(void **xpp, size_t nchars, const signed char *cp);
extern int
ncx_pad_putn_text(void **xpp, size_t nchars, const signed char *cp);
#else // ifdef __arm__
extern int
ncx_getn_text(const void **xpp, size_t nchars, char *cp);
extern int
@ -1012,7 +1006,6 @@ ncx_putn_text(void **xpp, size_t nchars, const char *cp);
extern int
ncx_pad_putn_text(void **xpp, size_t nchars, const char *cp);
#endif //ifdef __arm__
/* for symmetry */
#define ncx_getn_char_char(xpp, nelems, fillp) ncx_getn_text(xpp, nelems, fillp)

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@ NC_fill_$2(
*vp++ = $4;
}
}
return ncx_putn_$2_$1(xpp, nelems, fillp);
return ncx_putn_$2_$1(xpp, nelems, fillp ifelse(`$1',`char',,`,NULL'));
}
')dnl
@ -541,7 +541,11 @@ NCcoordck(NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
{
if(*coord > X_UINT_MAX) /* rkr: bug fix from previous X_INT_MAX */
return NC_EINVALCOORDS; /* sanity check */
#ifdef RELAX_COORD_BOUND
if(NC_readonly(ncp) && *coord > NC_get_numrecs(ncp))
#else
if(NC_readonly(ncp) && *coord >= NC_get_numrecs(ncp))
#endif
{
if(!NC_doNsync(ncp))
return NC_EINVALCOORDS;
@ -551,7 +555,11 @@ NCcoordck(NC3_INFO* ncp, const NC_var *varp, const size_t *coord)
const int status = read_numrecs(ncp);
if(status != NC_NOERR)
return status;
#ifdef RELAX_COORD_BOUND
if(*coord > NC_get_numrecs(ncp))
#else
if(*coord >= NC_get_numrecs(ncp))
#endif
return NC_EINVALCOORDS;
}
}
@ -578,7 +586,11 @@ fprintf(stderr," NCcoordck: ip %p, *ip %ld, up %p, *up %lu\n",
#endif /* CDEBUG */
/* cast needed for braindead systems with signed size_t */
#ifdef RELAX_COORD_BOUND
if((unsigned long) *ip > (unsigned long) *up )
#else
if((unsigned long) *ip >= (unsigned long) *up )
#endif
return NC_EINVALCOORDS;
}
@ -602,6 +614,11 @@ NCedgeck(const NC3_INFO* ncp, const NC_var *varp,
if(IS_RECVAR(varp))
{
#ifdef RELAX_COORD_BOUND
if (NC_readonly(ncp) &&
(start[0] == NC_get_numrecs(ncp) && edges[0] > 0))
return(NC_EINVALCOORDS);
#endif
start++;
edges++;
shp++;
@ -609,6 +626,10 @@ NCedgeck(const NC3_INFO* ncp, const NC_var *varp,
for(; start < end; start++, edges++, shp++)
{
#ifdef RELAX_COORD_BOUND
if ((unsigned long) *start == *shp && *edges > 0)
return(NC_EINVALCOORDS);
#endif
/* cast needed for braindead systems with signed size_t */
if((unsigned long) *edges > *shp ||
(unsigned long) *start + (unsigned long) *edges > *shp)
@ -680,12 +701,16 @@ putNCvx_$1_$2(NC3_INFO* ncp, const NC_var *varp,
size_t remaining = varp->xsz * nelems;
int status = NC_NOERR;
void *xp;
void *fillp;
if(nelems == 0)
return NC_NOERR;
assert(value != NULL);
fillp = malloc(varp->xsz);
status = NC3_inq_var_fill(varp, fillp);
for(;;)
{
size_t extent = MIN(remaining, ncp->chunk);
@ -696,7 +721,7 @@ putNCvx_$1_$2(NC3_INFO* ncp, const NC_var *varp,
if(lstatus != NC_NOERR)
return lstatus;
lstatus = ncx_putn_$1_$2(&xp, nput, value);
lstatus = ncx_putn_$1_$2(&xp, nput, value ifelse(`$1',`char',,`,fillp'));
if(lstatus != NC_NOERR && status == NC_NOERR)
{
/* not fatal to the loop */
@ -709,10 +734,11 @@ putNCvx_$1_$2(NC3_INFO* ncp, const NC_var *varp,
remaining -= extent;
if(remaining == 0)
break; /* normal loop exit */
offset += extent;
offset += (off_t)extent;
value += nput;
}
free(fillp);
return status;
}
@ -868,7 +894,7 @@ getNCvx_$1_$2(const NC3_INFO* ncp, const NC_var *varp,
remaining -= extent;
if(remaining == 0)
break; /* normal loop exit */
offset += extent;
offset += (off_t)extent;
value += nget;
}
@ -1168,14 +1194,18 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
#ifndef __CHAR_UNSIGNED__
return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
#else
return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_schar_schar(ncp,varp,start,nelems,value);
#endif
break;
case CASE(NC_BYTE,NC_BYTE):
return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_schar_schar(ncp,varp,start,nelems, (schar*)value);
break;
case CASE(NC_BYTE,NC_UBYTE):
return getNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
if (fIsSet(ncp->flags,NC_64BIT_DATA))
return getNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
else
/* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
break;
case CASE(NC_BYTE,NC_SHORT):
return getNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
@ -1202,7 +1232,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return getNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_SHORT,NC_BYTE):
return getNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_short_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_SHORT,NC_UBYTE):
return getNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1233,7 +1263,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_INT,NC_BYTE):
return getNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_int_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_INT,NC_UBYTE):
return getNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1264,7 +1294,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_FLOAT,NC_BYTE):
return getNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_float_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_FLOAT,NC_UBYTE):
return getNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1295,7 +1325,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_DOUBLE,NC_BYTE):
return getNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_double_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_DOUBLE,NC_UBYTE):
return getNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1329,7 +1359,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return getNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
break;
case CASE(NC_UBYTE,NC_BYTE):
return getNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_uchar_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UBYTE,NC_SHORT):
return getNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
@ -1357,7 +1387,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_USHORT,NC_BYTE):
return getNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_ushort_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_USHORT,NC_UBYTE):
return getNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1388,7 +1418,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_UINT,NC_BYTE):
return getNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_uint_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UINT,NC_UBYTE):
return getNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1419,7 +1449,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_INT64,NC_BYTE):
return getNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_longlong_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_INT64,NC_UBYTE):
return getNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1450,7 +1480,7 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_UINT64,NC_BYTE):
return getNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
return getNCvx_ulonglong_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UINT64,NC_UBYTE):
return getNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1500,10 +1530,14 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_char_char(ncp,varp,start,nelems,(char*)value);
break;
case CASE(NC_BYTE,NC_BYTE):
return putNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_schar_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_BYTE,NC_UBYTE):
return putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
if (fIsSet(ncp->flags,NC_64BIT_DATA))
return putNCvx_schar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
else
/* for CDF-1 and CDF-2, NC_BYTE is treated the same type as uchar memtype */
return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
break;
case CASE(NC_BYTE,NC_SHORT):
return putNCvx_schar_short(ncp,varp,start,nelems,(short*)value);
@ -1530,7 +1564,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_schar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_SHORT,NC_BYTE):
return putNCvx_short_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_short_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_SHORT,NC_UBYTE):
return putNCvx_short_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1560,7 +1594,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_short_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_INT,NC_BYTE):
return putNCvx_int_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_int_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_INT,NC_UBYTE):
return putNCvx_int_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1590,7 +1624,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_int_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_FLOAT,NC_BYTE):
return putNCvx_float_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_float_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_FLOAT,NC_UBYTE):
return putNCvx_float_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1620,7 +1654,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_float_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_DOUBLE,NC_BYTE):
return putNCvx_double_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_double_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_DOUBLE,NC_UBYTE):
return putNCvx_double_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1653,7 +1687,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_uchar_uchar(ncp,varp,start,nelems,(unsigned char*)value);
break;
case CASE(NC_UBYTE,NC_BYTE):
return putNCvx_uchar_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_uchar_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UBYTE,NC_SHORT):
return putNCvx_uchar_short(ncp,varp,start,nelems,(short*)value);
@ -1680,7 +1714,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_uchar_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_USHORT,NC_BYTE):
return putNCvx_ushort_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_ushort_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_USHORT,NC_UBYTE):
return putNCvx_ushort_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1710,7 +1744,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_ushort_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_UINT,NC_BYTE):
return putNCvx_uint_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_uint_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UINT,NC_UBYTE):
return putNCvx_uint_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1740,7 +1774,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_uint_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_INT64,NC_BYTE):
return putNCvx_longlong_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_longlong_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_INT64,NC_UBYTE):
return putNCvx_longlong_uchar(ncp,varp,start,nelems,(unsigned char*)value);
@ -1770,7 +1804,7 @@ writeNCv(NC3_INFO* ncp, const NC_var* varp, const size_t* start,
return putNCvx_longlong_ushort(ncp,varp,start,nelems,(unsigned short*)value);
break;
case CASE(NC_UINT64,NC_BYTE):
return putNCvx_ulonglong_schar(ncp,varp,start,nelems,(signed char*)value);
return putNCvx_ulonglong_schar(ncp,varp,start,nelems,(schar*)value);
break;
case CASE(NC_UINT64,NC_UBYTE):
return putNCvx_ulonglong_uchar(ncp,varp,start,nelems,(unsigned char*)value);

View File

@ -85,11 +85,7 @@ fault_v1hs(v1hs *gsp, size_t extent)
if(gsp->base != NULL)
{
#ifdef __arm__
const ptrdiff_t incr = (signed char *)gsp->pos - (signed char *)gsp->base;
#else
const ptrdiff_t incr = (char *)gsp->pos - (char *)gsp->base;
#endif
status = rel_v1hs(gsp);
if(status)
return status;
@ -107,11 +103,7 @@ fault_v1hs(v1hs *gsp, size_t extent)
gsp->pos = gsp->base;
#ifdef __arm__
gsp->end = (signed char *)gsp->base + gsp->extent;
#else
gsp->end = (char *)gsp->base + gsp->extent;
#endif
return NC_NOERR;
}
@ -128,13 +120,8 @@ fprintf(stderr, "nextread %lu, remaining %lu\n",
(unsigned long)nextread,
(unsigned long)((char *)gsp->end - (char *)gsp->pos));
#endif
#ifdef __arm__
if((signed char *)gsp->pos + nextread <= (signed char *)gsp->end)
return NC_NOERR;
#else
if((char *)gsp->pos + nextread <= (char *)gsp->end)
return NC_NOERR;
#endif
return fault_v1hs(gsp, nextread);
}
@ -150,10 +137,12 @@ v1h_put_size_t(v1hs *psp, const size_t *sp)
status = check_v1hs(psp, X_SIZEOF_INT64);
else
status = check_v1hs(psp, X_SIZEOF_SIZE_T);
if(status != NC_NOERR)
if(status != NC_NOERR)
return status;
if (psp->version == 5)
return ncx_put_int64(&psp->pos, *sp);
if (psp->version == 5) {
unsigned long long tmp = (unsigned long long) (*sp);
return ncx_put_uint64(&psp->pos, tmp);
}
else
return ncx_put_size_t(&psp->pos, sp);
}
@ -167,11 +156,11 @@ v1h_get_size_t(v1hs *gsp, size_t *sp)
status = check_v1hs(gsp, X_SIZEOF_INT64);
else
status = check_v1hs(gsp, X_SIZEOF_SIZE_T);
if(status != NC_NOERR)
if(status != NC_NOERR)
return status;
if (gsp->version == 5) {
long long tmp=0;
status = ncx_get_int64((const void **)(&gsp->pos), &tmp);
unsigned long long tmp=0;
status = ncx_get_uint64((const void **)(&gsp->pos), &tmp);
*sp = (size_t)tmp;
return status;
}
@ -187,18 +176,10 @@ v1h_get_size_t(v1hs *gsp, size_t *sp)
static int
v1h_put_nc_type(v1hs *psp, const nc_type *typep)
{
const int itype = (int) *typep;
int status = check_v1hs(psp, X_SIZEOF_INT);
if(status != NC_NOERR)
return status;
status = ncx_put_int_int(psp->pos, &itype);
#ifdef __arm__
psp->pos = (void *)((signed char *)psp->pos + X_SIZEOF_INT);
#else
psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT);
#endif
const unsigned int itype = (unsigned int) *typep;
int status = check_v1hs(psp, X_SIZEOF_INT);
if(status != NC_NOERR) return status;
status = ncx_put_uint32(&psp->pos, itype);
return status;
}
@ -207,16 +188,10 @@ v1h_put_nc_type(v1hs *psp, const nc_type *typep)
static int
v1h_get_nc_type(v1hs *gsp, nc_type *typep)
{
int type = 0;
int status = check_v1hs(gsp, X_SIZEOF_INT);
if(status != NC_NOERR)
return status;
status = ncx_get_int_int(gsp->pos, &type);
#ifdef __arm__
gsp->pos = (void *)((signed char *)gsp->pos + X_SIZEOF_INT);
#else
gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT);
#endif
unsigned int type = 0;
int status = check_v1hs(gsp, X_SIZEOF_INT);
if(status != NC_NOERR) return status;
status = ncx_get_uint32((const void**)(&gsp->pos), &type);
if(status != NC_NOERR)
return status;
@ -248,16 +223,10 @@ v1h_get_nc_type(v1hs *gsp, nc_type *typep)
static int
v1h_put_NCtype(v1hs *psp, NCtype type)
{
const int itype = (int) type;
int status = check_v1hs(psp, X_SIZEOF_INT);
if(status != NC_NOERR)
return status;
status = ncx_put_int_int(psp->pos, &itype);
#ifdef __arm__
psp->pos = (void *)((signed char *)psp->pos + X_SIZEOF_INT);
#else
psp->pos = (void *)((char *)psp->pos + X_SIZEOF_INT);
#endif
const unsigned int itype = (unsigned int) type;
int status = check_v1hs(psp, X_SIZEOF_INT);
if(status != NC_NOERR) return status;
status = ncx_put_uint32(&psp->pos, itype);
return status;
}
@ -265,21 +234,13 @@ v1h_put_NCtype(v1hs *psp, NCtype type)
static int
v1h_get_NCtype(v1hs *gsp, NCtype *typep)
{
int type = 0;
int status = check_v1hs(gsp, X_SIZEOF_INT);
if(status != NC_NOERR)
return status;
status = ncx_get_int_int(gsp->pos, &type);
#ifdef __arm__
gsp->pos = (void *)((signed char *)gsp->pos + X_SIZEOF_INT);
#else
gsp->pos = (void *)((char *)gsp->pos + X_SIZEOF_INT);
#endif
if(status != NC_NOERR)
return status;
/* else */
*typep = (NCtype) type;
unsigned int type = 0;
int status = check_v1hs(gsp, X_SIZEOF_INT);
if(status != NC_NOERR) return status;
status = ncx_get_uint32((const void**)(&gsp->pos), &type);
if(status != NC_NOERR) return status;
/* else */
*typep = (NCtype) type;
return NC_NOERR;
}
@ -340,11 +301,11 @@ static int
v1h_get_NC_string(v1hs *gsp, NC_string **ncstrpp)
{
int status;
size_t nchars = 0;
size_t padding, nchars = 0;
NC_string *ncstrp;
status = v1h_get_size_t(gsp, &nchars);
if(status != NC_NOERR)
if(status != NC_NOERR)
return status;
ncstrp = new_NC_string(nchars, NULL);
@ -353,7 +314,6 @@ v1h_get_NC_string(v1hs *gsp, NC_string **ncstrpp)
return NC_ENOMEM;
}
#if 0
/* assert(ncstrp->nchars == nchars || ncstrp->nchars - nchars < X_ALIGN); */
assert(ncstrp->nchars % X_ALIGN == 0);
@ -362,22 +322,33 @@ v1h_get_NC_string(v1hs *gsp, NC_string **ncstrpp)
status = check_v1hs(gsp, _RNDUP(ncstrp->nchars, X_ALIGN));
#endif
if(status != NC_NOERR)
if(status != NC_NOERR)
goto unwind_alloc;
status = ncx_pad_getn_text((const void **)(&gsp->pos),
nchars, ncstrp->cp);
if(status != NC_NOERR)
if(status != NC_NOERR)
goto unwind_alloc;
padding = _RNDUP(X_SIZEOF_CHAR * ncstrp->nchars, X_ALIGN)
- X_SIZEOF_CHAR * ncstrp->nchars;
if (padding > 0) {
/* CDF specification: Header padding uses null (\x00) bytes. */
char pad[X_ALIGN-1];
memset(pad, 0, X_ALIGN-1);
if (memcmp((char*)gsp->pos-padding, pad, padding) != 0) {
free_NC_string(ncstrp);
return NC_EINVAL;
}
}
*ncstrpp = ncstrp;
return NC_NOERR;
return NC_NOERR;
unwind_alloc:
free_NC_string(ncstrp);
return status;
}
/* End NC_string */
@ -614,6 +585,28 @@ ncx_len_NC_attr(const NC_attr *attrp, int version)
#undef MIN
#define MIN(mm,nn) (((mm) < (nn)) ? (mm) : (nn))
/*----< ncmpix_len_nctype() >------------------------------------------------*/
/* return the length of external data type */
static int
ncmpix_len_nctype(nc_type type) {
switch(type) {
case NC_BYTE:
case NC_CHAR:
case NC_UBYTE: return X_SIZEOF_CHAR;
case NC_SHORT: return X_SIZEOF_SHORT;
case NC_USHORT: return X_SIZEOF_USHORT;
case NC_INT: return X_SIZEOF_INT;
case NC_UINT: return X_SIZEOF_UINT;
case NC_FLOAT: return X_SIZEOF_FLOAT;
case NC_DOUBLE: return X_SIZEOF_DOUBLE;
case NC_INT64: return X_SIZEOF_INT64;
case NC_UINT64: return X_SIZEOF_UINT64;
default: fprintf(stderr,"ncmpix_len_nctype bad type %d\n",type);
assert(0);
}
return 0;
}
/*
* Put the values of an attribute
* The loop is necessary since attrp->nelems
@ -626,7 +619,7 @@ v1h_put_NC_attrV(v1hs *psp, const NC_attr *attrp)
const size_t perchunk = psp->extent;
size_t remaining = attrp->xsz;
void *value = attrp->xvalue;
size_t nbytes;
size_t nbytes, padding;
assert(psp->extent % X_ALIGN == 0);
@ -634,23 +627,24 @@ v1h_put_NC_attrV(v1hs *psp, const NC_attr *attrp)
nbytes = MIN(perchunk, remaining);
status = check_v1hs(psp, nbytes);
if(status != NC_NOERR)
if(status != NC_NOERR)
return status;
(void) memcpy(psp->pos, value, nbytes);
#ifdef __arm__
psp->pos = (void *)((signed char *)psp->pos + nbytes);
value = (void *)((signed char *)value + nbytes);
#else
psp->pos = (void *)((char *)psp->pos + nbytes);
value = (void *)((char *)value + nbytes);
#endif
remaining -= nbytes;
remaining -= nbytes;
} while(remaining != 0);
return NC_NOERR;
padding = attrp->xsz - ncmpix_len_nctype(attrp->type) * attrp->nelems;
if (padding > 0) {
/* CDF specification: Header padding uses null (\x00) bytes. */
memset((char*)psp->pos-padding, 0, padding);
}
return NC_NOERR;
}
/* Write a NC_attr to the header */
@ -691,29 +685,33 @@ v1h_get_NC_attrV(v1hs *gsp, NC_attr *attrp)
const size_t perchunk = gsp->extent;
size_t remaining = attrp->xsz;
void *value = attrp->xvalue;
size_t nget;
size_t nget, padding;
do {
nget = MIN(perchunk, remaining);
status = check_v1hs(gsp, nget);
if(status != NC_NOERR)
if(status != NC_NOERR)
return status;
(void) memcpy(value, gsp->pos, nget);
#ifdef __arm__
gsp->pos = (void *)((signed char *)gsp->pos + nget);
value = (void *)((signed char *)value + nget);
#else
gsp->pos = (void *)((char *)gsp->pos + nget);
value = (void *)((char *)value + nget);
#endif
remaining -= nget;
remaining -= nget;
} while(remaining != 0);
return NC_NOERR;
padding = attrp->xsz - ncmpix_len_nctype(attrp->type) * attrp->nelems;
if (padding > 0) {
/* CDF specification: Header padding uses null (\x00) bytes. */
char pad[X_ALIGN-1];
memset(pad, 0, X_ALIGN-1);
if (memcmp((char*)gsp->pos-padding, pad, (size_t)padding) != 0)
return NC_EINVAL;
}
return NC_NOERR;
}
@ -939,7 +937,7 @@ v1h_put_NC_var(v1hs *psp, const NC_var *varp)
if(status != NC_NOERR)
return status;
status = ncx_putn_longlong_int(&psp->pos,
varp->ndims, varp->dimids);
varp->ndims, varp->dimids, NULL);
if(status != NC_NOERR)
return status;
}
@ -948,7 +946,7 @@ v1h_put_NC_var(v1hs *psp, const NC_var *varp)
if(status != NC_NOERR)
return status;
status = ncx_putn_int_int(&psp->pos,
varp->ndims, varp->dimids);
varp->ndims, varp->dimids, NULL);
if(status != NC_NOERR)
return status;
}
@ -1345,21 +1343,23 @@ ncx_put_NC(const NC3_INFO* ncp, void **xpp, off_t offset, size_t extent)
}
if (ps.version == 5)
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic5), ncmagic5);
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic5), ncmagic5, NULL);
else if (ps.version == 2)
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic);
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic), ncmagic, NULL);
else
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic1), ncmagic1);
if(status != NC_NOERR)
status = ncx_putn_schar_schar(&ps.pos, sizeof(ncmagic1), ncmagic1, NULL);
if(status != NC_NOERR)
goto release;
{
const size_t nrecs = NC_get_numrecs(ncp);
if (ps.version == 5)
status = ncx_put_int64(&ps.pos, nrecs);
if (ps.version == 5) {
unsigned long long tmp = (unsigned long long) nrecs;
status = ncx_put_uint64(&ps.pos, tmp);
}
else
status = ncx_put_size_t(&ps.pos, &nrecs);
if(status != NC_NOERR)
if(status != NC_NOERR)
goto release;
}
@ -1486,8 +1486,8 @@ nc_get_NC(NC3_INFO* ncp)
{
size_t nrecs = 0;
if (gs.version == 5) {
long long tmp = 0;
status = ncx_get_int64((const void **)(&gs.pos), &tmp);
unsigned long long tmp = 0;
status = ncx_get_uint64((const void **)(&gs.pos), &tmp);
nrecs = (size_t)tmp;
}
else
@ -1497,11 +1497,8 @@ nc_get_NC(NC3_INFO* ncp)
NC_set_numrecs(ncp, nrecs);
}
#ifdef __arm__
assert((signed char *)gs.pos < (signed char *)gs.end);
#else
assert((char *)gs.pos < (char *)gs.end);
#endif
status = v1h_get_NC_dimarray(&gs, &ncp->dims);
if(status != NC_NOERR)
goto unwind_get;

View File

@ -484,6 +484,7 @@ out :
case NC_CHAR :
case NC_UBYTE :
case NC_SHORT :
case NC_USHORT :
if( varp->len%4 != 0 )
{
varp->len += 4 - varp->len%4; /* round up */

View File

@ -55,6 +55,18 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
if (!(grp = nc4_rec_find_grp(h5->root_grp, (ncid & GRP_ID_MASK))))
BAIL(NC_EBADGRPID);
/* Check varid */
if (varid != NC_GLOBAL) {
if (varid < 0 || varid >= grp->vars.nelems)
return NC_ENOTVAR;
if (grp->vars.value[varid] == NULL)
return NC_ENOTVAR;
assert(grp->vars.value[varid]->varid == varid);
}
if (name == NULL)
BAIL(NC_EBADNAME);
/* Normalize name. */
if ((retval = nc4_normalize_name(name, norm_name)))
BAIL(retval);
@ -221,18 +233,8 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
int i;
int res;
if (!name)
return NC_EBADNAME;
assert(nc && NC4_DATA(nc));
LOG((1, "nc4_put_att: ncid 0x%x varid %d name %s "
"file_type %d mem_type %d len %d", ncid, varid,
name, file_type, mem_type, len));
/* If len is not zero, then there must be some data. */
if (len && !data)
return NC_EINVAL;
/* Find info for this file and group, and set pointer to each. */
h5 = NC4_DATA(nc);
if (!(grp = nc4_rec_find_grp(h5->root_grp, (ncid & GRP_ID_MASK))))
@ -242,19 +244,6 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
if (h5->no_write)
return NC_EPERM;
/* Check and normalize the name. */
if ((retval = nc4_check_name(name, norm_name)))
return retval;
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
if(strcmp(name,*sp)==0) {
return NC_ENOTATT; /* Not settable */
}
}
}
/* Find att, if it exists. */
if (varid == NC_GLOBAL)
attlist = &grp->att;
@ -268,10 +257,34 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
assert(var->varid == varid);
}
if (!name)
return NC_EBADNAME;
/* Check and normalize the name. */
if ((retval = nc4_check_name(name, norm_name)))
return retval;
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
if(strcmp(name,*sp)==0) {
return NC_ENOTATT; /* Not settable */
}
}
}
for (att = *attlist; att; att = att->l.next)
if (!strcmp(att->name, norm_name))
break;
/* If len is not zero, then there must be some data. */
if (len && !data)
return NC_EINVAL;
LOG((1, "nc4_put_att: ncid 0x%x varid %d name %s "
"file_type %d mem_type %d len %d", ncid, varid,
name, file_type, mem_type, len));
if (!att)
{
/* If this is a new att, require define mode. */
@ -821,12 +834,6 @@ nc4_put_att_tc(int ncid, int varid, const char *name, nc_type file_type,
NC *nc;
NC_HDF5_FILE_INFO_T *h5;
if (!name || strlen(name) > NC_MAX_NAME)
return NC_EBADNAME;
LOG((3, "nc4_put_att_tc: ncid 0x%x varid %d name %s file_type %d "
"mem_type %d len %d", ncid, varid, name, file_type, mem_type, len));
/* The length needs to be positive (cast needed for braindead
systems with signed size_t). */
if((unsigned long) len > X_INT_MAX)
@ -840,6 +847,26 @@ nc4_put_att_tc(int ncid, int varid, const char *name, nc_type file_type,
h5 = NC4_DATA(nc);
assert(h5);
/* Check varid */
if (varid != NC_GLOBAL) {
/* Find info for this file and group, and set pointer to each. */
NC_GRP_INFO_T *grp;
if (!(grp = nc4_rec_find_grp(h5->root_grp, (ncid & GRP_ID_MASK))))
return NC_EBADGRPID;
if (varid < 0 || varid >= grp->vars.nelems)
return NC_ENOTVAR;
if (grp->vars.value[varid] == NULL)
return NC_ENOTVAR;
assert(grp->vars.value[varid]->varid == varid);
}
if (!name || strlen(name) > NC_MAX_NAME)
return NC_EBADNAME;
LOG((3, "nc4_put_att_tc: ncid 0x%x varid %d name %s file_type %d "
"mem_type %d len %d", ncid, varid, name, file_type, mem_type, len));
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** reserved = NC_RESERVED_ATT_LIST;
for(;*reserved;reserved++) {

View File

@ -632,8 +632,12 @@ nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
assert(dim && dim->dimid == var->dimids[d2]);
if (!dim->unlimited)
{
#ifdef RELAX_COORD_BOUND
if (start[d2] > (hssize_t)fdims[d2] ||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
#else
if (start[d2] >= (hssize_t)fdims[d2])
#endif
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > fdims[d2])
BAIL_QUIET(NC_EEDGE);
@ -965,8 +969,12 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
BAIL(retval);
/* Check for out of bound requests. */
#ifdef RELAX_COORD_BOUND
if (start[d2] > (hssize_t)ulen ||
(start[d2] == (hssize_t)ulen && count[d2] > 0))
#else
if (start[d2] >= (hssize_t)ulen && ulen > 0)
#endif
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > ulen)
BAIL_QUIET(NC_EEDGE);
@ -989,8 +997,12 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
else
{
/* Check for out of bound requests. */
#ifdef RELAX_COORD_BOUND
if (start[d2] > (hssize_t)fdims[d2] ||
(start[d2] == (hssize_t)fdims[d2] && count[d2] > 0))
#else
if (start[d2] >= (hssize_t)fdims[d2])
#endif
BAIL_QUIET(NC_EINVALCOORDS);
if (start[d2] + count[d2] > fdims[d2])
BAIL_QUIET(NC_EEDGE);

View File

@ -189,7 +189,7 @@ NCP__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t
assert(nc5);
/* causes implicitly defined warning; may be because of old installed pnetcdf? */
#if 0
#if 1
/* In PnetCDF ncmpi__enddef() is only implemented in v1.5.0 and later */
status = ncmpi__enddef(nc->int_ncid, mpi_h_minfree, mpi_v_align,
mpi_v_minfree, mpi_r_align);
@ -441,6 +441,7 @@ NCP_get_att(
if(status != NC_NOERR) return status;
status = NCP_inq_att(ncid,varid,name,&xtype,NULL);
if(status != NC_NOERR) return status;
if(memtype == NC_NAT) memtype = xtype;
@ -487,6 +488,14 @@ NCP_put_att(
int status;
MPI_Offset mpilen;
/* check if ncid is valid */
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR) return status;
/* check if varid is valid */
status = ncmpi_inq_varnatts(nc->int_ncid, varid, NULL);
if (status != NC_NOERR) return status;
if (!name || (strlen(name) > NC_MAX_NAME))
return NC_EBADNAME;
@ -495,9 +504,6 @@ NCP_put_att(
if(((unsigned long) len) > X_INT_MAX)
return NC_EINVAL;
status = NC_check_id(ncid, &nc);
if(status != NC_NOERR) return status;
mpilen = len;
switch (memtype) {

View File

@ -1,6 +1,6 @@
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include)
SET (nc_test_m4_SOURCES test_get test_put)
SET (nc_test_m4_SOURCES test_get test_put test_read test_write)
FOREACH (F ${nc_test_m4_SOURCES})
GEN_m4(${F})
ENDFOREACH()
@ -93,5 +93,5 @@ ENDIF()
## Specify files to be distributed by 'make dist'
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.sh)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} test_get.m4 test_put.m4 ref_tst_diskless2.cdl)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} test_get.m4 test_put.m4 test_read.m4 test_write.m4 ref_tst_diskless2.cdl)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -92,7 +92,8 @@ endif # USE_VALGRIND_TESTS
# Distribute the .c files so that m4 isn't required on the users
# machine.
EXTRA_DIST = test_get.m4 test_put.m4 run_valgrind_tests.sh \
run_diskless.sh run_diskless2.sh run_mmap.sh run_pnetcdf_test.sh
run_diskless.sh run_diskless2.sh run_mmap.sh run_pnetcdf_test.sh \
test_read.m4 test_write.m4
# ref_tst_diskless2.cdl is for diff comparison and to produce tst_diskless2.c
EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt

View File

@ -59,7 +59,7 @@ ifFail(const int expr, const int line, const char *file)
* "architecture" of this program.
*/
void
print_n_size_t(size_t nelems, const size_t *array)
print_n_size_t(int nelems, const size_t *array)
{
fprintf(stderr, "[");
while(nelems-- > 0)

View File

@ -24,10 +24,11 @@ __attribute__ ((format (printf, 1, 2)))
extern int ifFail(const int expr, const int line, const char *file);
extern void
print_n_size_t(size_t nelems, const size_t *array);
print_n_size_t(int nelems, const size_t *array);
#ifdef __cplusplus
}
#endif
#define IF(EXPR) if (ifFail(EXPR, __LINE__, __FILE__))
#define ELSE_NOK else {nok++;}

View File

@ -35,11 +35,11 @@ char dim_name[NDIMS][3];
size_t dim_len[NDIMS];
char var_name[NVARS][2+MAX_RANK];
nc_type var_type[NVARS];
size_t var_rank[NVARS];
int var_rank[NVARS];
int var_dimid[NVARS][MAX_RANK];
size_t var_shape[NVARS][MAX_RANK];
size_t var_nels[NVARS];
size_t var_natts[NVARS];
int var_natts[NVARS];
char att_name[NVARS][MAX_NATTS][2];
char gatt_name[NGATTS][3];
nc_type att_type[NVARS][NGATTS];
@ -156,7 +156,7 @@ main(int argc, char *argv[])
/* Initialize global variables defining test file */
init_gvars();
/* Write the test file, needed for the read-only tests below. */
/* Write the test file, needed for the read-only tests below. */
write_file(testfile);
/* delete any existing scratch netCDF file */
@ -355,6 +355,8 @@ main(int argc, char *argv[])
NC_TEST(nc_copy_att);
NC_TEST(nc_rename_att);
NC_TEST(nc_del_att);
NC_TEST(nc_against_pnetcdf);
/* keep below the last test, as it changes the default file format */
NC_TEST(nc_set_default_format);
}

File diff suppressed because it is too large Load Diff

View File

@ -82,7 +82,7 @@ test_nc_get_var1_$1(void)
err = toMixedBase(j, var_rank[i], var_shape[i], index);
IF (err)
error("error in toMixedBase 1");
expect = hash4( var_type[i], var_rank[i], index, NCT_ITYPE($1) );
expect = hash4(cdf_format, var_type[i], var_rank[i], index, NCT_ITYPE($1));
if (var_rank[i] == 0 && i%2 )
err = nc_get_var1_$1(ncid, i, NULL, &value);
else
@ -182,7 +182,7 @@ test_nc_get_var_$1(void)
err = toMixedBase(j, var_rank[i], var_shape[i], index);
IF (err)
error("error in toMixedBase 1");
expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ITYPE($1));
expect[j] = hash4(cdf_format,var_type[i], var_rank[i], index, NCT_ITYPE($1));
if (inRange3(expect[j],var_type[i], NCT_ITYPE($1))) {
allInIntRange = allInIntRange && expect[j] >= $1_min
&& expect[j] <= $1_max;
@ -366,7 +366,7 @@ test_nc_get_vara_$1(void)
error("error in toMixedBase 1");
for (d = 0; d < var_rank[i]; d++)
index[d] += start[d];
expect[j] = hash4(var_type[i], var_rank[i], index, NCT_ITYPE($1));
expect[j] = hash4(cdf_format,var_type[i], var_rank[i], index, NCT_ITYPE($1));
if (inRange3(expect[j],var_type[i], NCT_ITYPE($1))) {
allInIntRange = allInIntRange && expect[j] >= $1_min
&& expect[j] <= $1_max;
@ -560,7 +560,7 @@ test_nc_get_vars_$1(void)
error("error in toMixedBase 1");
for (d = 0; d < var_rank[i]; d++)
index2[d] = index[d] + index2[d] * stride[d];
expect[j] = hash4(var_type[i], var_rank[i], index2,
expect[j] = hash4(cdf_format,var_type[i], var_rank[i], index2,
NCT_ITYPE($1));
if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))) {
allInIntRange = allInIntRange && expect[j] >= $1_min
@ -766,7 +766,7 @@ test_nc_get_varm_$1(void)
error("error in toMixedBase 1");
for (d = 0; d < var_rank[i]; d++)
index2[d] = index[d] + index2[d] * stride[d];
expect[j] = hash4(var_type[i], var_rank[i], index2,
expect[j] = hash4(cdf_format,var_type[i], var_rank[i], index2,
NCT_ITYPE($1));
if (inRange3(expect[j],var_type[i],NCT_ITYPE($1))) {
allInIntRange = allInIntRange && expect[j] >= $1_min
@ -881,7 +881,7 @@ test_nc_get_att_$1(void)
error("Bad attribute name: status = %d", err);
allInExtRange = allInIntRange = 1;
for (k = 0; k < ATT_LEN(i,j); k++) {
expect[k] = hash4(ATT_TYPE(i,j), -1, &k, NCT_ITYPE($1));
expect[k] = hash4(cdf_format,ATT_TYPE(i,j), -1, &k, NCT_ITYPE($1));
if (inRange3(expect[k],ATT_TYPE(i,j),NCT_ITYPE($1))) {
allInIntRange = allInIntRange && expect[k] >= $1_min
&& expect[k] <= $1_max;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2039
nc_test/test_read.m4 Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2506
nc_test/test_write.m4 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -26,13 +26,12 @@
/* Limits of external types (based on those in ncx.h) */
#ifdef __CHAR_UNSIGNED__
#define X_CHAR_MIN SCHAR_MIN
#define X_CHAR_MAX SCHAR_MAX
#else
#define X_CHAR_MIN CHAR_MIN
#define X_CHAR_MAX CHAR_MAX
#endif //__unsigned_char__
/* Note: In CDF format specification, NC_CHAR is for text characters, which
* is considered an 8-bit unsigned integer. Since it is for printable text
* characters, its values should range from 0 (X_CHAR_MIN) to 255 (X_CHAR_MAX).
*/
#define X_CHAR_MIN 0
#define X_CHAR_MAX 255
#define X_BYTE_MIN (-128)
#define X_BYTE_MAX 127
@ -205,7 +204,7 @@ extern "C" {
# include <sys/types.h>
#endif
typedef signed char text;
typedef char text;
typedef signed char schar;
#ifndef HAVE_USHORT
@ -243,11 +242,11 @@ extern char dim_name[NDIMS][3];
extern size_t dim_len[NDIMS];
extern char var_name[NVARS][2+MAX_RANK];
extern nc_type var_type[NVARS];
extern size_t var_rank[NVARS];
extern int var_rank[NVARS];
extern int var_dimid[NVARS][MAX_RANK];
extern size_t var_shape[NVARS][MAX_RANK];
extern size_t var_nels[NVARS];
extern size_t var_natts[NVARS];
extern int var_natts[NVARS];
extern char att_name[NVARS][MAX_NATTS][2];
extern char gatt_name[NGATTS][3];
extern nc_type att_type[NVARS][NGATTS];
@ -267,220 +266,221 @@ extern size_t gatt_len[NGATTS];
extern const char *s_nc_type(nc_type);
extern void test_nc_strerror(void);
extern void test_nc_open(void);
extern void test_nc_close(void);
extern int test_nc_strerror(void);
extern int test_nc_open(void);
extern int test_nc_close(void);
extern void test_nc_inq(void);
extern void test_nc_inq_natts(void);
extern void test_nc_inq_ndims(void);
extern void test_nc_inq_nvars(void);
extern void test_nc_inq_unlimdim(void);
extern int test_nc_inq(void);
extern int test_nc_inq_natts(void);
extern int test_nc_inq_ndims(void);
extern int test_nc_inq_nvars(void);
extern int test_nc_inq_unlimdim(void);
extern void test_nc_inq_dimid(void);
extern void test_nc_inq_dim(void);
extern void test_nc_inq_dimlen(void);
extern void test_nc_inq_dimname(void);
extern int test_nc_inq_dimid(void);
extern int test_nc_inq_dim(void);
extern int test_nc_inq_dimlen(void);
extern int test_nc_inq_dimname(void);
extern void test_nc_inq_varid(void);
extern void test_nc_inq_vardimid(void);
extern void test_nc_inq_varname(void);
extern void test_nc_inq_varnatts(void);
extern void test_nc_inq_varndims(void);
extern void test_nc_inq_vartype(void);
extern void test_nc_inq_var(void);
extern int test_nc_inq_varid(void);
extern int test_nc_inq_vardimid(void);
extern int test_nc_inq_varname(void);
extern int test_nc_inq_varnatts(void);
extern int test_nc_inq_varndims(void);
extern int test_nc_inq_vartype(void);
extern int test_nc_inq_var(void);
extern void test_nc_get_var_double(void);
extern void test_nc_get_var_float(void);
extern void test_nc_get_var_int(void);
extern void test_nc_get_var_long(void);
extern void test_nc_get_var_schar(void);
extern void test_nc_get_var_short(void);
extern void test_nc_get_var_text(void);
extern void test_nc_get_var_uchar(void);
extern void test_nc_get_var(void);
extern void test_nc_get_var_ushort(void);
extern void test_nc_get_var_uint(void);
extern void test_nc_get_var_longlong(void);
extern void test_nc_get_var_ulonglong(void);
extern int test_nc_get_var_double(void);
extern int test_nc_get_var_float(void);
extern int test_nc_get_var_int(void);
extern int test_nc_get_var_long(void);
extern int test_nc_get_var_schar(void);
extern int test_nc_get_var_short(void);
extern int test_nc_get_var_text(void);
extern int test_nc_get_var_uchar(void);
extern int test_nc_get_var(void);
extern int test_nc_get_var_ushort(void);
extern int test_nc_get_var_uint(void);
extern int test_nc_get_var_longlong(void);
extern int test_nc_get_var_ulonglong(void);
extern void test_nc_get_var1_double(void);
extern void test_nc_get_var1_float(void);
extern void test_nc_get_var1_int(void);
extern void test_nc_get_var1_long(void);
extern void test_nc_get_var1_schar(void);
extern void test_nc_get_var1_short(void);
extern void test_nc_get_var1_text(void);
extern void test_nc_get_var1_uchar(void);
extern void test_nc_get_var1(void);
extern void test_nc_get_var1_ushort(void);
extern void test_nc_get_var1_uint(void);
extern void test_nc_get_var1_longlong(void);
extern void test_nc_get_var1_ulonglong(void);
extern int test_nc_get_var1_double(void);
extern int test_nc_get_var1_float(void);
extern int test_nc_get_var1_int(void);
extern int test_nc_get_var1_long(void);
extern int test_nc_get_var1_schar(void);
extern int test_nc_get_var1_short(void);
extern int test_nc_get_var1_text(void);
extern int test_nc_get_var1_uchar(void);
extern int test_nc_get_var1(void);
extern int test_nc_get_var1_ushort(void);
extern int test_nc_get_var1_uint(void);
extern int test_nc_get_var1_longlong(void);
extern int test_nc_get_var1_ulonglong(void);
extern void test_nc_get_vara_double(void);
extern void test_nc_get_vara_float(void);
extern void test_nc_get_vara_int(void);
extern void test_nc_get_vara_long(void);
extern void test_nc_get_vara_schar(void);
extern void test_nc_get_vara_short(void);
extern void test_nc_get_vara_text(void);
extern void test_nc_get_vara_uchar(void);
extern void test_nc_get_vara(void);
extern void test_nc_get_vara_ushort(void);
extern void test_nc_get_vara_uint(void);
extern void test_nc_get_vara_longlong(void);
extern void test_nc_get_vara_ulonglong(void);
extern int test_nc_get_vara_double(void);
extern int test_nc_get_vara_float(void);
extern int test_nc_get_vara_int(void);
extern int test_nc_get_vara_long(void);
extern int test_nc_get_vara_schar(void);
extern int test_nc_get_vara_short(void);
extern int test_nc_get_vara_text(void);
extern int test_nc_get_vara_uchar(void);
extern int test_nc_get_vara(void);
extern int test_nc_get_vara_ushort(void);
extern int test_nc_get_vara_uint(void);
extern int test_nc_get_vara_longlong(void);
extern int test_nc_get_vara_ulonglong(void);
extern void test_nc_get_vars(void);
extern void test_nc_get_vars_double(void);
extern void test_nc_get_vars_float(void);
extern void test_nc_get_vars_int(void);
extern void test_nc_get_vars_long(void);
extern void test_nc_get_vars_schar(void);
extern void test_nc_get_vars_short(void);
extern void test_nc_get_vars_text(void);
extern void test_nc_get_vars_uchar(void);
extern void test_nc_get_vars(void);
extern void test_nc_get_vars_ushort(void);
extern void test_nc_get_vars_uint(void);
extern void test_nc_get_vars_longlong(void);
extern void test_nc_get_vars_ulonglong(void);
extern int test_nc_get_vars(void);
extern int test_nc_get_vars_double(void);
extern int test_nc_get_vars_float(void);
extern int test_nc_get_vars_int(void);
extern int test_nc_get_vars_long(void);
extern int test_nc_get_vars_schar(void);
extern int test_nc_get_vars_short(void);
extern int test_nc_get_vars_text(void);
extern int test_nc_get_vars_uchar(void);
extern int test_nc_get_vars(void);
extern int test_nc_get_vars_ushort(void);
extern int test_nc_get_vars_uint(void);
extern int test_nc_get_vars_longlong(void);
extern int test_nc_get_vars_ulonglong(void);
extern void test_nc_get_varm(void);
extern void test_nc_get_varm_double(void);
extern void test_nc_get_varm_float(void);
extern void test_nc_get_varm_int(void);
extern void test_nc_get_varm_long(void);
extern void test_nc_get_varm_schar(void);
extern void test_nc_get_varm_short(void);
extern void test_nc_get_varm_text(void);
extern void test_nc_get_varm_uchar(void);
extern void test_nc_get_varm(void);
extern void test_nc_get_varm_ushort(void);
extern void test_nc_get_varm_uint(void);
extern void test_nc_get_varm_longlong(void);
extern void test_nc_get_varm_ulonglong(void);
extern int test_nc_get_varm(void);
extern int test_nc_get_varm_double(void);
extern int test_nc_get_varm_float(void);
extern int test_nc_get_varm_int(void);
extern int test_nc_get_varm_long(void);
extern int test_nc_get_varm_schar(void);
extern int test_nc_get_varm_short(void);
extern int test_nc_get_varm_text(void);
extern int test_nc_get_varm_uchar(void);
extern int test_nc_get_varm(void);
extern int test_nc_get_varm_ushort(void);
extern int test_nc_get_varm_uint(void);
extern int test_nc_get_varm_longlong(void);
extern int test_nc_get_varm_ulonglong(void);
extern void test_nc_get_att(void);
extern void test_nc_get_att_double(void);
extern void test_nc_get_att_float(void);
extern void test_nc_get_att_int(void);
extern void test_nc_get_att_long(void);
extern void test_nc_get_att_schar(void);
extern void test_nc_get_att_short(void);
extern void test_nc_get_att_text(void);
extern void test_nc_get_att_uchar(void);
extern void test_nc_get_att_ushort(void);
extern void test_nc_get_att_uint(void);
extern void test_nc_get_att_longlong(void);
extern void test_nc_get_att_ulonglong(void);
extern int test_nc_get_att(void);
extern int test_nc_get_att_double(void);
extern int test_nc_get_att_float(void);
extern int test_nc_get_att_int(void);
extern int test_nc_get_att_long(void);
extern int test_nc_get_att_schar(void);
extern int test_nc_get_att_short(void);
extern int test_nc_get_att_text(void);
extern int test_nc_get_att_uchar(void);
extern int test_nc_get_att_ushort(void);
extern int test_nc_get_att_uint(void);
extern int test_nc_get_att_longlong(void);
extern int test_nc_get_att_ulonglong(void);
extern void test_nc_put_att(void);
extern void test_nc_put_var_double(void);
extern void test_nc_put_var_float(void);
extern void test_nc_put_var_int(void);
extern void test_nc_put_var_long(void);
extern void test_nc_put_var_schar(void);
extern void test_nc_put_var_short(void);
extern void test_nc_put_var_text(void);
extern void test_nc_put_var_uchar(void);
extern void test_nc_put_var(void);
extern void test_nc_put_var_ushort(void);
extern void test_nc_put_var_uint(void);
extern void test_nc_put_var_longlong(void);
extern void test_nc_put_var_ulonglong(void);
extern int test_nc_put_att(void);
extern int test_nc_put_var_double(void);
extern int test_nc_put_var_float(void);
extern int test_nc_put_var_int(void);
extern int test_nc_put_var_long(void);
extern int test_nc_put_var_schar(void);
extern int test_nc_put_var_short(void);
extern int test_nc_put_var_text(void);
extern int test_nc_put_var_uchar(void);
extern int test_nc_put_var(void);
extern int test_nc_put_var_ushort(void);
extern int test_nc_put_var_uint(void);
extern int test_nc_put_var_longlong(void);
extern int test_nc_put_var_ulonglong(void);
extern void test_nc_put_var1_double(void);
extern void test_nc_put_var1_float(void);
extern void test_nc_put_var1_int(void);
extern void test_nc_put_var1_long(void);
extern void test_nc_put_var1_schar(void);
extern void test_nc_put_var1_short(void);
extern void test_nc_put_var1_text(void);
extern void test_nc_put_var1_uchar(void);
extern void test_nc_put_var1(void);
extern void test_nc_put_var1_ushort(void);
extern void test_nc_put_var1_uint(void);
extern void test_nc_put_var1_longlong(void);
extern void test_nc_put_var1_ulonglong(void);
extern int test_nc_put_var1_double(void);
extern int test_nc_put_var1_float(void);
extern int test_nc_put_var1_int(void);
extern int test_nc_put_var1_long(void);
extern int test_nc_put_var1_schar(void);
extern int test_nc_put_var1_short(void);
extern int test_nc_put_var1_text(void);
extern int test_nc_put_var1_uchar(void);
extern int test_nc_put_var1(void);
extern int test_nc_put_var1_ushort(void);
extern int test_nc_put_var1_uint(void);
extern int test_nc_put_var1_longlong(void);
extern int test_nc_put_var1_ulonglong(void);
extern void test_nc_put_vara_double(void);
extern void test_nc_put_vara_float(void);
extern void test_nc_put_vara_int(void);
extern void test_nc_put_vara_long(void);
extern void test_nc_put_vara_schar(void);
extern void test_nc_put_vara_short(void);
extern void test_nc_put_vara_text(void);
extern void test_nc_put_vara_uchar(void);
extern void test_nc_put_vara(void);
extern void test_nc_put_vara_ushort(void);
extern void test_nc_put_vara_uint(void);
extern void test_nc_put_vara_longlong(void);
extern void test_nc_put_vara_ulonglong(void);
extern int test_nc_put_vara_double(void);
extern int test_nc_put_vara_float(void);
extern int test_nc_put_vara_int(void);
extern int test_nc_put_vara_long(void);
extern int test_nc_put_vara_schar(void);
extern int test_nc_put_vara_short(void);
extern int test_nc_put_vara_text(void);
extern int test_nc_put_vara_uchar(void);
extern int test_nc_put_vara(void);
extern int test_nc_put_vara_ushort(void);
extern int test_nc_put_vara_uint(void);
extern int test_nc_put_vara_longlong(void);
extern int test_nc_put_vara_ulonglong(void);
extern void test_nc_put_vars_double(void);
extern void test_nc_put_vars_float(void);
extern void test_nc_put_vars_int(void);
extern void test_nc_put_vars_long(void);
extern void test_nc_put_vars_schar(void);
extern void test_nc_put_vars_short(void);
extern void test_nc_put_vars_text(void);
extern void test_nc_put_vars_uchar(void);
extern void test_nc_put_vars(void);
extern void test_nc_put_vars_ushort(void);
extern void test_nc_put_vars_uint(void);
extern void test_nc_put_vars_longlong(void);
extern void test_nc_put_vars_ulonglong(void);
extern int test_nc_put_vars_double(void);
extern int test_nc_put_vars_float(void);
extern int test_nc_put_vars_int(void);
extern int test_nc_put_vars_long(void);
extern int test_nc_put_vars_schar(void);
extern int test_nc_put_vars_short(void);
extern int test_nc_put_vars_text(void);
extern int test_nc_put_vars_uchar(void);
extern int test_nc_put_vars(void);
extern int test_nc_put_vars_ushort(void);
extern int test_nc_put_vars_uint(void);
extern int test_nc_put_vars_longlong(void);
extern int test_nc_put_vars_ulonglong(void);
extern void test_nc_put_varm_double(void);
extern void test_nc_put_varm_float(void);
extern void test_nc_put_varm_int(void);
extern void test_nc_put_varm_long(void);
extern void test_nc_put_varm_schar(void);
extern void test_nc_put_varm_short(void);
extern void test_nc_put_varm_text(void);
extern void test_nc_put_varm_uchar(void);
extern void test_nc_put_varm(void);
extern void test_nc_put_varm_ushort(void);
extern void test_nc_put_varm_uint(void);
extern void test_nc_put_varm_longlong(void);
extern void test_nc_put_varm_ulonglong(void);
extern int test_nc_put_varm_double(void);
extern int test_nc_put_varm_float(void);
extern int test_nc_put_varm_int(void);
extern int test_nc_put_varm_long(void);
extern int test_nc_put_varm_schar(void);
extern int test_nc_put_varm_short(void);
extern int test_nc_put_varm_text(void);
extern int test_nc_put_varm_uchar(void);
extern int test_nc_put_varm(void);
extern int test_nc_put_varm_ushort(void);
extern int test_nc_put_varm_uint(void);
extern int test_nc_put_varm_longlong(void);
extern int test_nc_put_varm_ulonglong(void);
extern void test_nc_put_att_double(void);
extern void test_nc_put_att_float(void);
extern void test_nc_put_att_int(void);
extern void test_nc_put_att_long(void);
extern void test_nc_put_att_schar(void);
extern void test_nc_put_att_short(void);
extern void test_nc_put_att_text(void);
extern void test_nc_put_att_uchar(void);
extern void test_nc_put_att_ushort(void);
extern void test_nc_put_att_uint(void);
extern void test_nc_put_att_longlong(void);
extern void test_nc_put_att_ulonglong(void);
extern int test_nc_put_att_double(void);
extern int test_nc_put_att_float(void);
extern int test_nc_put_att_int(void);
extern int test_nc_put_att_long(void);
extern int test_nc_put_att_schar(void);
extern int test_nc_put_att_short(void);
extern int test_nc_put_att_text(void);
extern int test_nc_put_att_uchar(void);
extern int test_nc_put_att_ushort(void);
extern int test_nc_put_att_uint(void);
extern int test_nc_put_att_longlong(void);
extern int test_nc_put_att_ulonglong(void);
extern void test_nc_create(void);
extern void test_nc_redef(void);
extern void test_nc_enddef(void);
extern void test_nc_sync(void);
extern void test_nc_abort(void);
extern void test_nc_def_dim(void);
extern void test_nc_rename_dim(void);
extern void test_nc_def_var(void);
extern void test_nc_rename_var(void);
extern void test_nc_copy_att(void);
extern int test_nc_create(void);
extern int test_nc_redef(void);
extern int test_nc_enddef(void);
extern int test_nc_sync(void);
extern int test_nc_abort(void);
extern int test_nc_def_dim(void);
extern int test_nc_rename_dim(void);
extern int test_nc_def_var(void);
extern int test_nc_rename_var(void);
extern int test_nc_copy_att(void);
extern void test_nc_inq_att(void);
extern void test_nc_inq_attname(void);
extern void test_nc_inq_attid(void);
extern void test_nc_inq_attlen(void);
extern void test_nc_inq_atttype(void);
extern int test_nc_inq_att(void);
extern int test_nc_inq_attname(void);
extern int test_nc_inq_attid(void);
extern int test_nc_inq_attlen(void);
extern int test_nc_inq_atttype(void);
extern void test_nc_rename_att(void);
extern void test_nc_del_att(void);
extern void test_nc_set_fill(void);
extern void test_nc_set_default_format(void);
extern int test_nc_rename_att(void);
extern int test_nc_del_att(void);
extern int test_nc_set_fill(void);
extern int test_nc_set_default_format(void);
extern int test_nc_against_pnetcdf(void);
void print_nok(int nok);
@ -508,26 +508,28 @@ typedef enum {
#define NCT_ULONGLONG NCT_UINT64
} nct_itype;
int inRange3(const double value, const nc_type datatype, const nct_itype itype);
int inRange3(const int cdf_format, const double value, const nc_type datatype, const nct_itype itype);
int equal(const double x, const double y, nc_type extType, nct_itype itype);
int equal2(const double x, const double y, nc_type extType);
int int_vec_eq(const int *v1, const int *v2, const int n);
int roll( int n );
size_t roll( size_t n );
int
toMixedBase(
size_t number, /* number to be converted to mixed base */
size_t length,
const size_t base[], /* dimensioned [length], base[0] ignored */
size_t result[]); /* dimensioned [length] */
int length,
const size_t base[], /* dimensioned [length], base[0] ignored */
size_t result[]); /* dimensioned [length] */
size_t
fromMixedBase(
size_t length,
int length,
size_t number[], /* dimensioned [length] */
size_t base[]); /* dimensioned [length], base[0] ignored */
size_t base[]); /* dimensioned [length], base[0] ignored */
int nc2dbl ( const nc_type datatype, const void *p, double *result);
@ -536,6 +538,7 @@ int dbl2nc ( const double d, const nc_type datatype, void *p);
double hash( const nc_type type, const int rank, const size_t *index );
double hash4(
const int cdf_format,
const nc_type type,
const int rank,
const size_t *index,
@ -563,8 +566,12 @@ void check_file(char *filename);
int file_create(const char *filename, int cmode, int *ncid);
int file__create(const char *filename, int cmode, size_t initialsz, size_t *bufrsizehintp, int *ncid);
int file_open(const char *filename, int omode, int *ncid);
char* nc_err_code_name(int err);
#ifdef __cplusplus
}
#endif

View File

@ -136,7 +136,7 @@ main(int argc, char **argv)
signed char schar_in[ATT_LEN], schar_out[ATT_LEN] = {NC_MIN_BYTE, 1, NC_MAX_BYTE};
unsigned char uchar_in[ATT_LEN];
short short_in[ATT_LEN], short_out[ATT_LEN] = {NC_MIN_SHORT, -128, NC_MAX_SHORT};
int int_in[ATT_LEN], int_out[ATT_LEN] = {-100000, 128, 100000};
int int_in[ATT_LEN], int_out[ATT_LEN] = {-100000, 127, 100000};
float float_in[ATT_LEN], float_out[ATT_LEN] = {-0.5, 0.25, 0.125};
double double_in[ATT_LEN], double_out[ATT_LEN] = {-0.25, .5, 0.125};
long long longlong_in[ATT_LEN] = {-1LL, -1LL, -1LL};
@ -211,8 +211,10 @@ main(int argc, char **argv)
* supported C types. though the conversion may encounter
* out-of-range values */
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_INT_NAME, uchar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0 || i == 2) continue;
if (uchar_in[i] != (unsigned char) int_out[i]) ERR;
}
/* This was bug NCF-171: on 32-bit platforms, bad values returned */
if (nc_get_att_longlong(ncid, NC_GLOBAL, ATT_INT_NAME, longlong_in)) ERR;
@ -346,8 +348,10 @@ main(int argc, char **argv)
for (i = 0; i < ATT_LEN; i++)
if (short_in[i] != short_out[i]) ERR;
if (nc_get_att_short(ncid, NC_GLOBAL, ATT_INT_NAME, short_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0 || i == 2) continue;
if (short_in[i] != (short) int_out[i]) ERR;
}
if (nc_get_att_short(ncid, NC_GLOBAL, ATT_FLOAT_NAME, short_in)) ERR;
for (i = 0; i < ATT_LEN; i++)
if (short_in[i] != (short) float_out[i]) ERR;
@ -360,11 +364,15 @@ main(int argc, char **argv)
for (i = 0; i < ATT_LEN; i++)
if (schar_in[i] != schar_out[i]) ERR;
if (nc_get_att_schar(ncid, NC_GLOBAL, ATT_SHORT_NAME, schar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0 || i == 2) continue;
if (schar_in[i] != (signed char) short_out[i]) ERR;
}
if (nc_get_att_schar(ncid, NC_GLOBAL, ATT_INT_NAME, schar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0 || i == 2) continue;
if (schar_in[i] != (signed char) int_out[i]) ERR;
}
if (nc_get_att_schar(ncid, NC_GLOBAL, ATT_FLOAT_NAME, schar_in)) ERR;
for (i = 0; i < ATT_LEN; i++)
if (schar_in[i] != (signed char) float_out[i]) ERR;
@ -373,22 +381,25 @@ main(int argc, char **argv)
if (schar_in[i] != (signed char) double_out[i]) ERR;
/* Read all atts (except text) as uchar. */
/* Shouldn't this get an NC_ERANGE error for storing -128 into an unsigned char? Possible bug ... */
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_SCHAR_NAME, uchar_in)) ERR;
for (i = 0; i < ATT_LEN; i++)
if (uchar_in[i] != (unsigned char) schar_out[i]) ERR;
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_SHORT_NAME, uchar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
if (uchar_in[i] != (unsigned char) short_out[i]) ERR;
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_INT_NAME, uchar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0 || i == 2) continue;
if (uchar_in[i] != (unsigned char) int_out[i]) ERR;
}
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_FLOAT_NAME, uchar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0) continue;
if (uchar_in[i] != (unsigned char) float_out[i]) ERR;
}
if (nc_get_att_uchar(ncid, NC_GLOBAL, ATT_DOUBLE_NAME, uchar_in) != NC_ERANGE) ERR;
for (i = 0; i < ATT_LEN; i++)
for (i = 0; i < ATT_LEN; i++) {
if (i == 0) continue;
if (uchar_in[i] != (unsigned char) double_out[i]) ERR;
}
/* Read all atts (except text) into long long variable. */
if (nc_get_att_longlong(ncid, NC_GLOBAL, ATT_SCHAR_NAME, longlong_in)) ERR;

View File

@ -104,6 +104,7 @@ test_small_atts(const char *testfile)
{
/* Create null-terminated text string of correct length. */
strncpy(att, source, t);
att[t] = '\0';
/* Create a file with one attribute. */
if (file_create(testfile, NC_CLOBBER, &ncid)) ERR;

File diff suppressed because it is too large Load Diff

View File

@ -70,8 +70,12 @@ create_file(int format, unsigned char *uchar_out)
if (nc_def_var(ncid, VAR1_NAME, NC_BYTE, 1, dimids, &varid)) ERR;
if (nc_enddef(ncid)) ERR;
retval = nc_put_var_uchar(ncid, varid, uchar_out);
if ((format != NC_FORMAT_NETCDF4) && retval) ERR;
if ((format == NC_FORMAT_NETCDF4) && (retval != NC_ERANGE)) ERR;
if (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_64BIT_DATA)
{
if (retval != NC_ERANGE) ERR;
}
else if (retval != NC_NOERR) ERR;
if (nc_close(ncid)) ERR;
return NC_NOERR;
}
@ -105,7 +109,7 @@ check_file(int format, unsigned char *uchar_out)
* because range errors are not generated for byte type
* conversions. */
res = nc_get_var_uchar(ncid, 0, uchar_in);
if (format == NC_FORMAT_NETCDF4)
if (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_64BIT_DATA)
{
if (res != NC_ERANGE) ERR;
}

View File

@ -502,8 +502,11 @@ test_redef(int format)
/* Add att. */
ret = nc_put_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, NC_BYTE, 1, &uchar_out);
if (format != NC_FORMAT_NETCDF4 && ret) ERR;
else if (format == NC_FORMAT_NETCDF4 && ret != NC_ERANGE) ERR;
if (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_64BIT_DATA)
{
if (ret != NC_ERANGE) ERR;
}
else if (ret) ERR;
/* Check it out. */
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
@ -539,7 +542,7 @@ test_redef(int format)
if (nc_get_att_int(ncid, NC_GLOBAL, REDEF_ATT2_NAME, &int_in)) ERR;
if (int_in != short_out) ERR;
ret = nc_get_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, &uchar_in);
if (format == NC_FORMAT_NETCDF4)
if (format == NC_FORMAT_NETCDF4 || format == NC_FORMAT_64BIT_DATA)
{
if (ret != NC_ERANGE) ERR;
}

View File

@ -121,7 +121,10 @@ tst_ncf213.cdl tst_ncf213.nc tst_h_scalar.cdl tst_h_scalar.nc \
tst_mud4_chars.cdl tst_mud4_chars.nc \
inttags.nc inttags4.nc tst_inttags.cdl tst_inttags4.cdl \
tst_dimsize_classic.nc tst_dimsize_64offset.nc tst_dimsize_64data.nc \
nc4_fileinfo.nc hdf5_fileinfo.hdf
nc4_fileinfo.nc hdf5_fileinfo.hdf \
ref_hdf5_compat1.nc ref_hdf5_compat2.nc ref_hdf5_compat3.nc \
ref_tst_compounds.nc ref_tst_dims.nc ref_tst_interops4.nc \
ref_tst_xplatform2_1.nc ref_tst_xplatform2_2.nc
# These files all have to be included with the distribution.
EXTRA_DIST = run_tests.sh tst_64bit.sh tst_output.sh test0.cdl \
@ -158,3 +161,6 @@ tst_ncgen4_diff.sh tst_ncgen4_cycle.sh ref_ctest.c ref_ctest64.c
CLEANFILES += results/*.nc results/*.dmp results/*.dmp2 tmp*.cdl tst_bug324.nc
DISTCLEANFILES = results
clean-local:
-rm -rf results