Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch related to Issue258 #319

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
39b47f6
borrow ncx.m4 from PnetCDF
Oct 6, 2016
4b7d9fe
add 4 new subroutines defined in ncx.m4
Oct 6, 2016
c277853
use ncx_get_uint64 instead of ncx_get_int64
Oct 6, 2016
688ad6d
handle special case when calling _uchar APIs to access NC_BYTE attrib…
Oct 6, 2016
f6804fc
handle special case when calling _uchar APIs to access NC_BYTE variab…
Oct 6, 2016
1f32277
use ncx_get_uint32 instead of ncx_get_int_int
Oct 6, 2016
4b911c1
add a rule to delete folder results
Oct 6, 2016
dd19b27
handle special case when calling _uchar APIs to access NC_BYTE attrib…
Oct 6, 2016
f8813bb
handle special case when calling _uchar APIs to access NC_BYTE attrib…
Oct 6, 2016
e1643f9
handle special case when calling _uchar APIs to access NC_BYTE attrib…
Oct 6, 2016
0eff6cb
add CDF format checking in hash4 to exclude the NC_BYTE-to-uchar exce…
Oct 8, 2016
f336af5
now ncx.m4 is the same as PnetCDF's except PNETCDF is not defined
Oct 10, 2016
aacb3c2
borrow PnetCDF test_get.m4
Oct 10, 2016
ecc851b
borrow PnetCDF test_put.m4
Oct 10, 2016
9cf0125
revise sunroutine equal, add equal2 for matched ityep and xtype APIs,…
Oct 10, 2016
835ff7c
make test subroutine return nok, add comments on X_CHAR_MIN and X_CHA…
Oct 10, 2016
dbb9be5
temporally disable __arm__ for testing
Oct 10, 2016
8bf99ab
silence compile warning from -Wsign-conversion
Oct 10, 2016
c4a148e
type cast (char) before comparison
Oct 10, 2016
4725c14
move varid check right after ncid
Oct 12, 2016
125ca43
add NULL name check
Oct 12, 2016
df91c19
add NULL name check
Oct 12, 2016
fbbed1f
move ncid check to the first and add varid check before name check
Oct 13, 2016
0d24dcc
copy ncx.m4 from PnetCDF
Oct 13, 2016
3a93d84
borrow some m4 files from PnetCDF
Oct 13, 2016
ac86d8c
Update CMakeLists.txt due to test_read.c and test_write.c have been r…
Oct 13, 2016
beac085
more updates due to renaming test_read.c and test_write.c to m4 files
Oct 13, 2016
6737a38
add back a fix for NC_EDIMSIZE
Oct 13, 2016
08afcf1
add missing tests from the original netCDF
Oct 13, 2016
075bc07
ncmpi__enddef has been available since PnetCDF 1.5.0
Oct 18, 2016
c282d18
add two fill value inquiry subroutines
Oct 25, 2016
d78ec89
SCHAR_MAX is 127, not 128
Oct 25, 2016
87fab92
match type of a subroutine argument
Oct 25, 2016
7fbde1b
add a new option ERANGE_FILL to use fill values when NC_ERANGE occurs…
Oct 25, 2016
39ea096
make ERANGE_FILL default
Oct 25, 2016
f19e4ce
sync m4 files with PnetCDF
Oct 25, 2016
309303e
remove argument fillv for get APIs as we use default fill values for …
Oct 28, 2016
04e5ff4
sync with master branch
Oct 28, 2016
7572e1c
add sizeof checks for unsigned data types
Oct 28, 2016
06c1f74
silence gcc compile warnings when using -Wconversion
Oct 30, 2016
5137be2
add configure/cmake option to disable erange_fill
Nov 3, 2016
e357696
sync with PnetCDF on use of NC_ENULLSTART and NC_ENULLCOUNT
Nov 4, 2016
2081ae7
add configure option --enable-relax-coord-bound for issue #243
Nov 13, 2016
e8cfdbb
Merge branch 'master' into issue258
Nov 13, 2016
154b805
check PnetCDF setting on erange-fill and adjust
Nov 14, 2016
38e40a1
sync with PnetCDF nc_test files (add a few more testings)
Nov 14, 2016
33865df
skip tests that are incompatible with the earlier PnetCDF versions, e…
Nov 18, 2016
ab73a57
Merge branch 'master' into issue258
Nov 25, 2016
3889617
bug fix: record size alignment for NC_USHORT is missing
Nov 28, 2016
340f0d2
Classic Format Specification says: Header padding uses null (\x00) bytes
Nov 28, 2016
4cdbf7d
Merge branch 'master' into issue258
Dec 1, 2016
fe9685d
implement an error code precedence
Dec 1, 2016
fc40f92
bug fix: values stored in NC_attr.xvalue are in external representati…
Feb 10, 2017
a25e100
bug fix for nc_test: should have used char for read as char is used f…
Mar 10, 2017
dad5514
Merge branch 'master' into issue258
WardF Mar 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
74 changes: 66 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -984,22 +984,22 @@ 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")
string(REGEX REPLACE "[^0-9]" "" pnetcdf_minor "${pnetcdf_minor_string}")
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")
Expand All @@ -1008,13 +1008,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)
Expand Down Expand Up @@ -1242,9 +1295,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
Expand Down Expand Up @@ -1338,7 +1395,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)
Expand Down Expand Up @@ -1806,6 +1863,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"
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

85 changes: 85 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.])
Expand Down Expand Up @@ -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],
Expand Down
11 changes: 0 additions & 11 deletions include/nc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 */
Expand Down
6 changes: 6 additions & 0 deletions include/nc3internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
10 changes: 0 additions & 10 deletions libdispatch/dstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,8 @@ NC_check_name(const char *name)
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;
Expand Down Expand Up @@ -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;

Expand Down
Loading