Merge branch 'master' into master

This commit is contained in:
Ed Hartnett 2017-08-10 12:47:17 -06:00 committed by GitHub
commit eb98d238d0
108 changed files with 438 additions and 288 deletions

View File

@ -955,9 +955,7 @@ IF(ENABLE_LARGE_FILE_SUPPORT)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LARGEADDRESSAWARE")
ELSE()
SET(_FILE_OFFSET_BITS 64)
SET(_LARGEFILE64_SOURCE TRUE)
SET(_LARGEFILE_SOURCE TRUE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64")
ENDIF()
ENDIF()
@ -1234,6 +1232,8 @@ CHECK_INCLUDE_FILE("BaseTsd.h" HAVE_BASETSD_H)
CHECK_INCLUDE_FILE("stddef.h" HAVE_STDDEF_H)
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
CHECK_INCLUDE_FILE("winsock2.h" HAVE_WINSOCK2_H)
CHECK_INCLUDE_FILE("ftw.h" HAVE_FTW_H)
CHECK_INCLUDE_FILES("time.h;sys/time.h" TIME_WITH_SYS_TIME)

View File

@ -7,8 +7,9 @@ This file contains a high-level description of this package's evolution. Release
## 4.5.0 - TBD
### 4.5.0-rc2 - TBD
### 4.5.0-rc2 - August 7, 2017
* [Bug Fix] Addressed an issue with how cmake was implementing large file support on 32-bit systems. See [GitHub #385](https://github.com/Unidata/netcdf-c/issues/385) for more information.
* [Bug Fix] Addressed an issue where ncgen would not respect keyword case. See [GitHub #310](https://github.com/Unidata/netcdf-c/issues/310) for more information.
### 4.5.0-rc1 - June 5, 2017

1
cf
View File

@ -111,7 +111,6 @@ FLAGS="$FLAGS --enable-logging"
#FLAGS="$FLAGS --enable-jna"
#FLAGS="$FLAGS --disable-properties-attribute"
#FLAGS="$FLAGS --disable-silent-rules"
#FLAGS="$FLAGS --enable-dap4"
#FLAGS="$FLAGS --with-testservers=remotestserver.localhost:8083"
if test "x$PAR4" != x1 ; then

View File

@ -1,5 +1,14 @@
# Visual Studio
VS=1
#VSSETUP=1
#export NCPATHDEBUG=1
if test "x$VSSETUP" = x1 ; then
CFG="Debug"
else
CFG="Release"
fi
# Is netcdf-4 and/or DAP enabled?
NC4=1
@ -33,13 +42,13 @@ NCLIB=`pwd`
if test "x$VS" != x ; then
# Visual Studio
#CFG="RelWithDebInfo"
CFG="Release"
NCLIB="${NCLIB}/build/liblib/$CFG"
export PATH="${NCLIB}:${PATH}"
cmake $FLAGS ..
if test "x$VSSETUP" = x ; then
cmake --build . --config ${CFG}
cmake --build . --config ${CFG} --target RUN_TESTS
fi
else
# GCC
NCLIB="${NCLIB}/build/liblib"

View File

@ -13,7 +13,12 @@
* https://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h
*/
#cmakedefine HAVE_WINSOCK2_H
#ifdef HAVE_WINSOCK2_H
#define _WINSOCKAPI_
#endif
#if _MSC_VER>=1900
#define STDC99
@ -358,6 +363,9 @@ are set when opening a binary file on Windows. */
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the <ftw.h> header file. */
#cmakedefine HAVE_FTW_H 1
/* Define to 1 if you have the `strlcat' function. */
#cmakedefine HAVE_STRLCAT 1

View File

@ -790,6 +790,9 @@ AC_CHECK_HEADERS([sys/resource.h])
# Check for <stdbool.h> that conforms to C99 requirements
AC_HEADER_STDBOOL
# See if we have ftw.h to walk directory trees
AC_CHECK_HEADERS([ftw.h])
# Check for these functions...
AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr strcat strcpy \
strdup strcasecmp strtod strtoll strtoull strstr \
@ -804,11 +807,10 @@ AC_ARG_ENABLE([diskless],
test "x$enable_diskless" = xno || enable_diskless=yes
AC_MSG_RESULT($enable_diskless)
# Check for enable DAP
if test "x$enable_dap" = "xyes" -a "xenable_diskless" = xno ; then
AC_MSG_NOTICE([--enable-dap requires --enable-diskless])
AC_MSG_NOTICE([dap support disabled])
enable_dap=no
# If DAP enabled and diskless not enabled, then warn of consequences
if test "x$enable_dap" = "xyes" -a "x$enable_diskless" = xno ; then
AC_MSG_NOTICE([Warning: DAP support is enabled but diskless support is disabled.])
AC_MSG_NOTICE([=> temporary files will be created + reclaimed when using DAP.])
fi
# disable dap4 if netcdf-4 is disabled

View File

@ -2,7 +2,6 @@ SET(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
remove_definitions(-DDLL_EXPORT)
ADD_SUBDIRECTORY(baseline)
ADD_SUBDIRECTORY(baselineraw)
ADD_SUBDIRECTORY(baselineremote)

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -11,10 +11,7 @@
</Structure>
</Types>
<Variables>
<Struct name="s" type="/s">
<Map name="/s.x"/>
<Map name="/s.y"/>
</Struct>
<Struct name="s" type="/s"/>
</Variables>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -8,7 +8,6 @@ dimensions:
_Anonymous2 = 2 ;
variables:
s_t s(_Anonymous2, _Anonymous2) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
string :_dap4.ce = "/s[0:2:3][0:1]" ;

View File

@ -8,7 +8,6 @@ dimensions:
_Anonymous2 = 2 ;
variables:
s_t s(_Anonymous2, _Anonymous2) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
string :_dap4.ce = "/s[0:2:3][0:1]" ;

View File

@ -17,8 +17,6 @@
<Struct name="s" type="/s">
<Dim name="/_Anonymous2"/>
<Dim name="/_Anonymous2"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Struct>
</Variables>
<Attribute name="_dap4.ce" type="String">

View File

@ -9,7 +9,6 @@ dimensions:
dy = 3 ;
variables:
s_t s(dx, dy) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -9,7 +9,6 @@ dimensions:
dy = 3 ;
variables:
s_t s(dx, dy) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -18,8 +18,6 @@
<Struct name="s" type="/s">
<Dim name="/dx"/>
<Dim name="/dy"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Struct>
</Variables>
<Attribute name="_DAP4_Little_Endian" type="UInt8">

View File

@ -11,7 +11,7 @@ variables:
float z(dx) ;
float t(dy) ;
s_t s(dx, dy) ;
string s:_edu.ucar.maps = "/z", "/t" ;
string s:_edu.ucar.maps = "/z", "/t" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -11,7 +11,7 @@ variables:
float z(dx) ;
float t(dy) ;
s_t s(dx, dy) ;
string s:_edu.ucar.maps = "/z", "/t" ;
string s:_edu.ucar.maps = "/z", "/t" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -14,7 +14,6 @@ types:
}; // x_t
variables:
x_t x ;
string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -14,7 +14,6 @@ types:
}; // x_t
variables:
x_t x ;
string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -19,10 +19,7 @@
</Structure>
</Types>
<Variables>
<Struct name="x" type="/x">
<Map name="/x_field1.x"/>
<Map name="/x_field1.y"/>
</Struct>
<Struct name="x" type="/x"/>
</Variables>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -11,10 +11,7 @@
</Structure>
</Types>
<Variables>
<Struct name="s" type="/s">
<Map name="/s.x"/>
<Map name="/s.y"/>
</Struct>
<Struct name="s" type="/s"/>
</Variables>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -8,7 +8,6 @@ dimensions:
_Anonymous2 = 2 ;
variables:
s_t s(_Anonymous2, _Anonymous2) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
string :_dap4.ce = "/s[0:2:3][0:1]" ;

View File

@ -9,7 +9,6 @@ dimensions:
dy = 3 ;
variables:
s_t s(dx, dy) ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -14,7 +14,6 @@ types:
}; // x_t
variables:
x_t x ;
string x:_edu.ucar.maps = "/x_field1.x", "/x_field1.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -6,7 +6,6 @@ types:
}; // s_t
variables:
s_t s ;
string s:_edu.ucar.maps = "/s.x", "/s.y" ;
// global attributes:
:_DAP4_Little_Endian = 1UB ;

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

View File

@ -51,7 +51,7 @@
</Opaque>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Dim name="/d5"/>
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -51,7 +51,7 @@
</Opaque>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Dim name="/d5"/>
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -33,12 +33,12 @@
<String name="vs"/>
<Opaque name="vo" _edu.ucar.opaque.size="8"/>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>
<Enum name="secondary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -33,12 +33,12 @@
<String name="vs"/>
<Opaque name="vo"/>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>
<Enum name="secondary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -20,7 +20,7 @@
<EnumConst name="Missing" value="127"/>
</Enumeration>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -24,7 +24,7 @@
</Attribute>
<Group name="h">
<Enum name="primary_cloud" enum="/cloud_class_t">
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -21,7 +21,7 @@
</Enumeration>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Dim size="2"/>
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -22,7 +22,7 @@
</Enumeration>
<Enum name="primary_cloud" enum="/cloud_class_t">
<Dim name="/d5"/>
<Attribute name="_FillValue" type="String">
<Attribute name="_FillValue" type="/cloud_class_t">
<Value value="Missing"/>
</Attribute>
</Enum>

View File

@ -8,8 +8,6 @@
<Structure name="s">
<Int32 name="x"/>
<Int32 name="y"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Structure>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -10,8 +10,6 @@
<Int32 name="y"/>
<Dim size="2"/>
<Dim size="2"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Structure>
<Attribute name="_dap4.ce" type="String">
<Value value="/s[0:2:3][0:1]"/>

View File

@ -12,8 +12,6 @@
<Int32 name="y"/>
<Dim name="/dx"/>
<Dim name="/dy"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Structure>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -14,8 +14,6 @@
<Int32 name="x"/>
<Int32 name="y"/>
</Structure>
<Map name="/x.field1.x"/>
<Map name="/x.field1.y"/>
</Structure>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -8,8 +8,6 @@
<Structure name="s">
<Int32 name="x"/>
<Int32 name="y"/>
<Map name="/s.x"/>
<Map name="/s.y"/>
</Structure>
<Attribute name="_DAP4_Little_Endian" type="UInt8">
<Value value="1"/>

View File

@ -2,5 +2,5 @@ FILE(GLOB COPY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*)
FILE(COPY ${COPY_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")

Binary file not shown.

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ${srcdir}/d4test_common.sh
echo "test_data.sh:"
cd ${DAPTESTFILES}
F=`ls -1 *.dap | sed -e 's/[.]dap//g' | tr '\r\n' ' '`
cd $WD

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ${srcdir}/d4test_common.sh
echo "test_meta.sh:"
cd ${DMRTESTFILES}
F=`ls -1 *.dmr | sed -e 's/[.]dmr//g' | tr '\r\n' ' '`
cd $WD
@ -15,7 +17,7 @@ STEM=`echo $f | cut -d. -f 1`
if test -e ${CDLTESTFILES}/${STEM}.cdl ; then
CDL="${CDL} ${STEM}"
else
echo "Not found: ${CDLTESTFILES}/${STEM}.cdl"
echo "Not found: ${CDLTESTFILES}/${STEM}.cdl; ignored"
fi
done

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ${srcdir}/d4test_common.sh
echo "test_parse.sh:"
cd ${DMRTESTFILES}
F=`ls -1 *.dmr | sed -e 's/[.]dmr//' |tr '\r\n' ' '`
cd $WD

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ${srcdir}/d4test_common.sh
echo "test_raw.sh:"
# Compute the set of testfiles
PUSHD ${srcdir}/daptestfiles
F=`ls -1d *.dap`

View File

@ -5,6 +5,8 @@ if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ${srcdir}/d4test_common.sh
echo "test_remote.sh:"
#BIG=1
#NOCSUM=1

View File

@ -10,15 +10,16 @@
#include <stdio.h>
#include "ncexternl.h"
#ifndef WINPATH
#ifdef _MSC_VER
#define WINPATH 1
#endif
#ifdef __MINGW32__
#define WINPATH 1
#endif
#endif
/* path converter */
/* Path Converter */
EXTERNL char* NCpathcvt(const char* path);
#ifdef WINPATH

View File

@ -209,17 +209,16 @@ dapcvtattrval(nc_type etype, void* dst, NClist* src)
ok = 0;
switch (etype) {
case NC_BYTE: {
case NC_BYTE: { /* Note that in DAP2, this is unsigned 8-bit integer */
/*Needs special handling because Windows sscanf does not do %hhd*/
char* p = (char*)dstmem;
#ifdef _MSC_VER
int ival;
ok = sscanf(s,"%d%n",&ival,&nread);
#ifdef _MSC_VER
_ASSERTE(_CrtCheckMemory());
if(ival < NC_MIN_BYTE || ival > NC_MAX_BYTE) ok = 0;
*p = (char)ival;
#else
ok = sscanf(s,"%hhu%n",p,&nread);
#endif
if(ival < 0 || ival > NC_MAX_UBYTE) ok = 0;
*p = (char)ival;
} break;
case NC_CHAR: {
signed char* p = (signed char*)dstmem;

View File

@ -20,9 +20,10 @@ dapbreakpoint(int err)
}
int
dapthrow(int err)
dapthrow(int err, int lineno, const char* filename)
{
if(err == 0) return err;
fprintf(stderr,"$dapthrow: err=%d line=%d file=%s\n",err,lineno,filename); fflush(stderr);
return dapbreakpoint(err);
}
#endif

View File

@ -27,7 +27,7 @@
#undef PARSEDEBUG
/* Warning: setting CATCHERROR has significant performance impact */
#define CATCHERROR
#undef CATCHERROR
#include <stdarg.h>
#include <assert.h>
@ -51,11 +51,11 @@ extern int dappanic(const char* fmt, ...);
#ifdef CATCHERROR
/* Place breakpoint on dapbreakpoint to catch errors close to where they occur*/
#define THROW(e) dapthrow(e)
#define THROWCHK(e) (void)dapthrow(e)
#define THROW(e) dapthrow(e,__LINE__,__FILE__)
#define THROWCHK(e) (void)dapthrow(e,__LINE__,__FILE__)
extern int dapbreakpoint(int err);
extern int dapthrow(int err);
extern int dapthrow(int err, int lineno, const char* filename);
#else
#define THROW(e) (e)
#define THROWCHK(e)

View File

@ -126,7 +126,11 @@ typedef struct NCDAPCOMMON {
NCCDF cdf;
NCOC oc;
NCCONTROLS controls; /* Control flags and parameters */
int nc3id; /* nc3 file ncid used to hold metadata */
struct {
int realfile; /* 1 => we created actual temp file */
char* filename; /* of the substrate file */
int nc3id; /* substrate nc4 file ncid used to hold metadata; not same as external id */
} substrate;
} NCDAPCOMMON;
/**************************************************/
@ -306,6 +310,6 @@ extern int nc__opendap(void);
#define getncid(drno) (((NC*)drno)->ext_ncid)
#define getdap(drno) ((NCDAPCOMMON*)((NC*)drno)->dispatchdata)
#define getnc3id(drno) (getdap(drno)->nc3id)
#define getnc3id(drno) (getdap(drno)->substrate.nc3id)
#endif /*NCCOMMON_H*/

View File

@ -283,7 +283,7 @@ NCD2_get_vars(int ncid, int varid,
/* See ncd2dispatch.c for other version */
int
NCD2_open(const char * path, int mode,
NCD2_open(const char* path, int mode,
int basepe, size_t *chunksizehintp,
int useparallel, void* mpidata,
NC_Dispatch* dispatch, NC* drno)
@ -295,13 +295,15 @@ NCD2_open(const char * path, int mode,
int nc3id = -1;
if(path == NULL)
return NC_EDAPURL;
if(dispatch == NULL) PANIC("NCD3_open: no dispatch table");
{ncstat = NC_EDAPURL; goto done;}
if(dispatch == NULL)
PANIC("NCD3_open: no dispatch table");
/* Setup our NC and NCDAPCOMMON state*/
dapcomm = (NCDAPCOMMON*)calloc(1,sizeof(NCDAPCOMMON));
if(dapcomm == NULL) {ncstat = NC_ENOMEM; goto done;}
if(dapcomm == NULL)
{ncstat = NC_ENOMEM; goto done;}
NCD2_DATA_SET(drno,dapcomm);
drno->int_ncid = nc__pseudofd(); /* create a unique id */
@ -364,26 +366,34 @@ NCD2_open(const char * path, int mode,
/* Create fake file name: exact name must be unique,
but is otherwise irrelevant because we are using NC_DISKLESS
*/
snprintf(tmpname,sizeof(tmpname),"%d",drno->int_ncid);
snprintf(tmpname,sizeof(tmpname),"tmp_%d",drno->int_ncid);
/* Now, use the file to create the hidden, in-memory netcdf file.
We want this hidden file to always be NC_CLASSIC, so we need to
force default format temporarily in case user changed it.
If diskless is enabled, then create file in-memory, else
create an actual temporary file in the file system.
*/
{
int new = 0; /* format netcdf-3 */
int old = 0;
int ncflags = NC_CLOBBER|NC_CLASSIC_MODEL;
#ifdef USE_DISKLESS
ncflags |= NC_DISKLESS;
#endif
nc_set_default_format(new,&old); /* save and change */
ncstat = nc_create(tmpname,NC_DISKLESS|NC_CLASSIC_MODEL,&nc3id);
ncstat = nc_create(tmpname,ncflags,&nc3id);
nc_set_default_format(old,&new); /* restore */
dapcomm->substrate.realfile = ((ncflags & NC_DISKLESS) != 0);
dapcomm->substrate.filename = strdup(tmpname);
if(tmpname == NULL) ncstat = NC_ENOMEM;
dapcomm->substrate.nc3id = nc3id;
}
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
dapcomm->nc3id = nc3id;
/* Avoid fill */
nc_set_fill(nc3id,NC_NOFILL,NULL);
}
dapcomm->oc.dapconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
dapcomm->oc.dapconstraint->projections = nclistnew();
dapcomm->oc.dapconstraint->selections = nclistnew();
@ -673,7 +683,7 @@ builddims(NCDAPCOMMON* dapcomm)
if(dapcomm->cdf.recorddim != NULL) {
CDFnode* unlimited = dapcomm->cdf.recorddim;
definename = getdefinename(unlimited);
ncstat = nc_def_dim(dapcomm->nc3id,
ncstat = nc_def_dim(dapcomm->substrate.nc3id,
definename,
NC_UNLIMITED,
&unlimited->ncid);
@ -681,7 +691,7 @@ builddims(NCDAPCOMMON* dapcomm)
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
/* get the id for the substrate */
ncstat = NC_check_id(dapcomm->nc3id,&ncsub);
ncstat = NC_check_id(dapcomm->substrate.nc3id,&ncsub);
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
#if 0
nc3sub = (NC3_INFO*)&ncsub->dispatchdata;
@ -700,7 +710,7 @@ builddims(NCDAPCOMMON* dapcomm)
fprintf(stderr,"define: dim: %s=%ld\n",dim->ncfullname,(long)dim->dim.declsize);
#endif
definename = getdefinename(dim);
ncstat = nc_def_dim(dapcomm->nc3id,definename,dim->dim.declsize,&dimid);
ncstat = nc_def_dim(dapcomm->substrate.nc3id,definename,dim->dim.declsize,&dimid);
if(ncstat != NC_NOERR) {
THROWCHK(ncstat); nullfree(definename); goto done;
}
@ -772,7 +782,7 @@ fprintf(stderr,"[%ld]",dim->dim.declsize);
}
fprintf(stderr,"\n");
#endif
ncstat = nc_def_var(dapcomm->nc3id,
ncstat = nc_def_var(dapcomm->substrate.nc3id,
definename,
var->externaltype,
ncrank,
@ -833,7 +843,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root)
}
}
if(ncbyteslength(buf) > 0) {
ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_sequence_dimensions",
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_sequence_dimensions",
ncbyteslength(buf),ncbytescontents(buf));
}
}
@ -844,12 +854,12 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root)
if(dapparamcheck(dapcomm,"show","translate")) {
/* Add a global attribute to show the translation */
ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_translate",
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_translate",
strlen("netcdf-3"),"netcdf-3");
}
if(dapparamcheck(dapcomm,"show","url")) {
if(dapcomm->oc.rawurltext != NULL)
ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_url",
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_url",
strlen(dapcomm->oc.rawurltext),dapcomm->oc.rawurltext);
}
if(dapparamcheck(dapcomm,"show","dds")) {
@ -860,7 +870,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root)
/* replace newlines with spaces*/
nltxt = nulldup(txt);
for(p=nltxt;*p;p++) {if(*p == '\n' || *p == '\r' || *p == '\t') {*p = ' ';}};
ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_dds",strlen(nltxt),nltxt);
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_dds",strlen(nltxt),nltxt);
nullfree(nltxt);
}
}
@ -871,7 +881,7 @@ buildglobalattrs(NCDAPCOMMON* dapcomm, CDFnode* root)
if(txt != NULL) {
nltxt = nulldup(txt);
for(p=nltxt;*p;p++) {if(*p == '\n' || *p == '\r' || *p == '\t') {*p = ' ';}};
ncstat = nc_put_att_text(dapcomm->nc3id,NC_GLOBAL,"_das",strlen(nltxt),nltxt);
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,NC_GLOBAL,"_das",strlen(nltxt),nltxt);
nullfree(nltxt);
}
}
@ -913,9 +923,9 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari
}
dapexpandescapes(newstring);
if(newstring[0]=='\0')
ncstat = nc_put_att_text(dapcomm->nc3id,varid,att->name,1,newstring);
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,varid,att->name,1,newstring);
else
ncstat = nc_put_att_text(dapcomm->nc3id,varid,att->name,strlen(newstring),newstring);
ncstat = nc_put_att_text(dapcomm->substrate.nc3id,varid,att->name,strlen(newstring),newstring);
free(newstring);
if(ncstat) goto done;
} else {
@ -945,7 +955,7 @@ buildattribute(NCDAPCOMMON* dapcomm, NCattribute* att, nc_type vartype, int vari
_ASSERTE(_CrtCheckMemory());
#endif
if(ncstat) {nullfree(mem); goto done;}
ncstat = nc_put_att(dapcomm->nc3id,varid,att->name,atype,nvalues,mem);
ncstat = nc_put_att(dapcomm->substrate.nc3id,varid,att->name,atype,nvalues,mem);
#ifdef _MSC_VER
_ASSERTE(_CrtCheckMemory());
#endif
@ -1764,6 +1774,11 @@ freeNCDAPCOMMON(NCDAPCOMMON* dapcomm)
dcefree((DCEnode*)dapcomm->oc.dapconstraint);
dapcomm->oc.dapconstraint = NULL;
/* Note that the ncio layer will figure out that the tmp file needs to be deleted,
so we do not have to do it.
*/
nullfree(dapcomm->substrate.filename); /* always reclaim */
free(dapcomm);
return NC_NOERR;

View File

@ -9,7 +9,7 @@
#include "d4read.h"
#include "d4curlfunctions.h"
#if defined(_WIN32) || defined(_WIN64)
#ifdef _MSC_VER
#include <process.h>
#include <direct.h>
#endif
@ -29,6 +29,7 @@ static void freeInfo(NCD4INFO*);
static int paramcheck(NCD4INFO*, const char* key, const char* subkey);
static const char* getparam(NCD4INFO* info, const char* key);
static int set_curl_properties(NCD4INFO*);
static void d4removecookies(const char* path);
/**************************************************/
/* Constants */
@ -93,21 +94,32 @@ NCD4_open(const char * path, int mode,
else
snprintf(tmpname,sizeof(tmpname),"tmp_%d",nc->int_ncid);
/* Now, use the file to create the hidden, in-memory netcdf file.
/* Now, use the file to create the hidden substrate netcdf file.
We want this hidden file to always be NC_NETCDF4, so we need to
force default format temporarily in case user changed it.
If diskless is enabled, then create file in-memory, else
create an actual temporary file in the file system.
*/
{
int new = NC_NETCDF4;
int old = 0;
int ncflags = NC_DISKLESS|NC_NETCDF4|NC_CLOBBER;
if(FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY))
int ncid = 0;
int ncflags = NC_NETCDF4|NC_CLOBBER;
#ifdef USE_DISKLESS
ncflags |= NC_DISKLESS;
#endif
if(FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY)) {
/* Cause data to be dumped to real file */
ncflags |= NC_WRITE;
ncflags &= ~(NC_DISKLESS); /* use real file */
}
nc_set_default_format(new,&old); /* save and change */
ret = nc_create(tmpname,ncflags,&d4info->substrate.nc4id);
ret = nc_create(tmpname,ncflags,&ncid);
nc_set_default_format(old,&new); /* restore */
d4info->substrate.realfile = ((ncflags & NC_DISKLESS) == 0);
d4info->substrate.filename = strdup(tmpname);
if(tmpname == NULL) ret = NC_ENOMEM;
d4info->substrate.nc4id = ncid;
}
if(ret != NC_NOERR) goto done;
/* Avoid fill */
@ -280,7 +292,21 @@ freeInfo(NCD4INFO* d4info)
nullfree(d4info->data.ondiskfilename);
if(d4info->data.ondiskfile != NULL)
fclose(d4info->data.ondiskfile);
nullfree(d4info->substrate.filename);
if(d4info->substrate.realfile
&& !FLAGSET(d4info->controls.debugflags,NCF_DEBUG_COPY)) {
/* We used real file, so we need to delete the temp file
unless we are debugging.
Assume caller has done nc_close|nc_abort on the ncid.
Note that in theory, this should not be necessary since
AFAIK the substrate file is still in def mode, and
when aborted, it should be deleted. But that is not working
for some reason, so we delete it ourselves.
*/
if(d4info->substrate.filename != NULL) {
unlink(d4info->substrate.filename);
}
}
nullfree(d4info->substrate.filename); /* always reclaim */
NCD4_reclaimMeta(d4info->substrate.metadata);
free(d4info);
}
@ -294,7 +320,6 @@ freeCurl(NCD4curl* curl)
nullfree(curl->errdata.code);
nullfree(curl->errdata.message);
nullfree(curl->curlflags.useragent);
nullfree(curl->curlflags.cookiejar);
nullfree(curl->curlflags.netrc);
nullfree(curl->ssl.certificate);
nullfree(curl->ssl.key);
@ -304,6 +329,9 @@ freeCurl(NCD4curl* curl)
nullfree(curl->proxy.host);
nullfree(curl->proxy.userpwd);
nullfree(curl->creds.userpwd);
if(curl->curlflags.createdflags & COOKIECREATED)
d4removecookies(curl->curlflags.cookiejar);
nullfree(curl->curlflags.cookiejar);
}
/* Define the set of protocols known to be constrainable */
@ -353,32 +381,28 @@ set_curl_properties(NCD4INFO* d4info)
if(d4info->curl->curlflags.cookiejar == NULL) {
/* If no cookie file was defined, define a default */
char tmp[4096+1];
int ok;
#if defined(_WIN32) || defined(_WIN64)
int pid = _getpid();
#else
pid_t pid = getpid();
#endif
snprintf(tmp,sizeof(tmp)-1,"%s/%s.%ld/",NCD4_globalstate->tempdir,"netcdf",(long)pid);
#if defined(_WIN32) || defined(_WIN64)
ok = _mkdir(tmp);
#else
ok = mkdir(tmp,S_IRUSR | S_IWUSR | S_IXUSR);
#endif
if(ok != 0 && errno != EEXIST) {
fprintf(stderr,"Cannot create cookie directory\n");
goto fail;
}
char* path = NULL;
char* name = NULL;
int len;
errno = 0;
/* Create the unique cookie file name */
ok = NCD4_mktmp(tmp,&d4info->curl->curlflags.cookiejar);
d4info->curl->curlflags.createdflags |= COOKIECREATED;
len =
strlen(NCD4_globalstate->tempdir)
+ 1 /* '/' */
+ strlen("ncd4cookies");
path = (char*)malloc(len+1);
if(path == NULL) return NC_ENOMEM;
snprintf(path,len,"%s/nc4cookies",NCD4_globalstate->tempdir);
/* Create the unique cookie file name */
ok = NCD4_mktmp(path,&name);
free(path);
if(ok != NC_NOERR && errno != EEXIST) {
fprintf(stderr,"Cannot create cookie file\n");
goto fail;
}
d4info->curl->curlflags.cookiejar = name;
d4info->curl->curlflags.createdflags |= COOKIECREATED;
errno = 0;
}
assert(d4info->curl->curlflags.cookiejar != NULL);
@ -489,3 +513,13 @@ getparam(NCD4INFO* info, const char* key)
return NULL;
return value;
}
static void
d4removecookies(const char* path)
{
#ifdef _MSC_VER
DeleteFile(path);
#else
remove(path);
#endif
}

View File

@ -49,16 +49,16 @@ NCD4_readDAP(NCD4INFO* state, int flags)
ncurisetconstraints(url,state->constraint);
#endif
readurl = ncuribuild(url,NULL,".dods",NCURISVC);
if(readurl == NULL)
if(readurl == NULL)
return THROW(NC_ENOMEM);
if (state->debug > 0)
if (state->debug > 0)
{fprintf(stderr, "fetch url=%s\n", readurl);fflush(stderr);}
stat = NCD4_fetchurl_file(state->curl, readurl, state->data.ondiskfile,
&state->data.datasize, &lastmod);
nullfree(readurl);
if(stat == NC_NOERR)
state->data.daplastmodified = lastmod;
if (state->debug > 0)
if (state->debug > 0)
{fprintf(stderr,"fetch complete\n"); fflush(stderr);}
}
}
@ -167,7 +167,7 @@ readfile(const NCURI* uri, const char* suffix, NCbytes* packet)
#ifdef O_BINARY
flags |= O_BINARY;
#endif
fprintf(stderr,"XXX: flags=0x%x file=%s\n",flags,filename);
fd = NCopen2(filename,flags);
if(fd < 0) {
nclog(NCLOGERR,"open failed:%s",filename);

View File

@ -207,7 +207,7 @@ backslashEscape(const char* s)
}
/* Parse an fqn into a sequence of names;
initially using '/', then '.' */
using '/', and then (conditionally) '.' */
int
NCD4_parseFQN(const char* fqn0, NClist* pieces)
{
@ -239,6 +239,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces)
break;
}
}
#ifdef ALLOWFIELDMAPS
/* Step 2, walk the final piece to break up based on '.' */
for(p=start;*p;) {
switch(*p) {
@ -255,6 +256,7 @@ NCD4_parseFQN(const char* fqn0, NClist* pieces)
break;
}
}
#endif
count++; /* acct for last piece */
/* Step 3: capture and de-scape the pieces */
for(p=fqn;count > 0;count--) {

View File

@ -13,6 +13,12 @@ are defined here.
#undef COMPILEBYDEFAULT
/*
Control if struct fields can be map targets.
Currently turned off because semantics are unclear.
*/
#undef ALLOWFIELDMAPS
#define long64 long long
#define ncerror int
@ -217,7 +223,8 @@ typedef struct NCD4serial {
/* This will be passed out of the parse */
struct NCD4meta {
NCD4INFO* controller;
int ncid; /* root ncid of the substrate netcdf-4 file; copy of NCD4parse argument*/
int ncid; /* root ncid of the substrate netcdf-4 file;
warning: copy of NCD4Info.substrate.nc4id */
NCD4node* root;
NCD4mode mode; /* Are we reading DMR (only) or DAP (includes DMR) */
NClist* allnodes; /*list<NCD4node>*/
@ -345,6 +352,7 @@ struct NCD4INFO {
long daplastmodified;
} data;
struct {
int realfile; /* 1 => we created actual temp file */
char* filename; /* of the substrate file */
int nc4id; /* substrate nc4 file ncid used to hold metadata; not same as external id */
NCD4meta* metadata;

View File

@ -118,9 +118,11 @@ done:
/*!
Given an existing file, figure out its format
and return that format value (NC_FORMATX_XXX)
in model arg.
in model arg. Assume any path conversion was
already performed at a higher level.
*/
static int NC_check_file_type(const char *path, int flags, void *parameters,
static int
NC_check_file_type(const char *path, int flags, void *parameters,
int* model, int* version)
{
char magic[MAGIC_NUMBER_LEN];
@ -139,6 +141,7 @@ static int NC_check_file_type(const char *path, int flags, void *parameters,
} else {/* presumably a real file */
/* Get the 4-byte magic from the beginning of the file. Don't use posix
* for parallel, use the MPI functions instead. */
#ifdef USE_PARALLEL
if (use_parallel) {
MPI_File fh;
@ -169,19 +172,18 @@ static int NC_check_file_type(const char *path, int flags, void *parameters,
#else
struct stat st;
#endif
if(path == NULL || strlen(path)==0)
if(path == NULL || strlen(path)==0)
{status = NC_EINVAL; goto done;}
if (!(fp = fopen(path, "r")))
if (!(fp = fopen(path, "r")))
{status = errno; goto done;}
#ifdef HAVE_SYS_STAT_H
/* The file must be at least MAGIC_NUMBER_LEN in size,
/* The file must be at least MAGIC_NUMBER_LEN in size,
or otherwise the following fread will exhibit unexpected
behavior. */
/* Windows and fstat have some issues, this will work around that. */
/* Windows and fstat have some issues, this will work around that. */
#ifdef HAVE_FILE_LENGTH_I64
if((file_len = _filelengthi64(fileno(fp))) < 0) {
fclose(fp);
@ -189,7 +191,6 @@ static int NC_check_file_type(const char *path, int flags, void *parameters,
goto done;
}
if(file_len < MAGIC_NUMBER_LEN) {
fclose(fp);
status = NC_ENOTNC;
@ -1659,6 +1660,10 @@ NC_create(const char *path0, int cmode, size_t initialsz,
return stat;
}
#ifndef USE_DISKLESS
cmode &= (~ NC_DISKLESS); /* Force off */
#endif
#ifdef WINPATH
/* Need to do path conversion */
path = NCpathcvt(path0);
@ -1811,8 +1816,8 @@ NC_open(const char *path0, int cmode,
int stat = NC_NOERR;
NC* ncp = NULL;
NC_Dispatch* dispatcher = NULL;
int inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY);
int diskless = ((cmode & NC_DISKLESS) == NC_DISKLESS);
int inmemory = 0;
int diskless = 0;
/* Need pieces of information for now to decide model*/
int model = 0;
int isurl = 0;
@ -1826,10 +1831,22 @@ NC_open(const char *path0, int cmode,
if(stat) return stat;
}
/* Attempt to do file path conversion: note that this will do
nothing if path is a 'file:...' url, so it will need to be
repeated in protocol code: libdap2 and libdap4
*/
#ifndef USE_DISKLESS
/* Clean up cmode */
cmode &= (~ NC_DISKLESS);
#endif
inmemory = ((cmode & NC_INMEMORY) == NC_INMEMORY);
diskless = ((cmode & NC_DISKLESS) == NC_DISKLESS);
#ifdef WINPATH
/* Need to do path conversion */
path = NCpathcvt(path0);
fprintf(stderr,"XXX: path0=%s path=%s\n",path0,path); fflush(stderr);
#else
path = nulldup(path0);
#endif

View File

@ -18,6 +18,8 @@
#include "ncexternl.h"
#include "ncwinpath.h"
#undef PATHFORMAT
/*
Code to provide some path conversion code so that
cygwin and (some) mingw paths can be passed to open/fopen
@ -38,6 +40,8 @@ static char* windrive = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static size_t cdlen = 10; /* strlen("/cygdrive/") */
static int pathdebug = -1;
EXTERNL
char* /* caller frees */
NCpathcvt(const char* path)
@ -47,7 +51,14 @@ NCpathcvt(const char* path)
char* q;
size_t pathlen;
if(path == NULL) return NULL; /* defensive driving */
if(path == NULL) goto done; /* defensive driving */
/* Check for path debug env vars */
if(pathdebug < 0) {
const char* s = getenv("NCPATHDEBUG");
pathdebug = (s == NULL ? 0 : 1);
}
pathlen = strlen(path);
/* 1. look for MSYS path /D/... */
@ -57,7 +68,7 @@ NCpathcvt(const char* path)
&& (path[2] == '/' || path[2] == '\\' || path[2] == '\0')) {
/* Assume this is a mingw path */
outpath = (char*)malloc(pathlen+3); /* conservative */
if(outpath == NULL) return NULL;
if(outpath == NULL) goto done;
q = outpath;
*q++ = path[1];
*q++ = ':';
@ -76,8 +87,8 @@ NCpathcvt(const char* path)
|| path[cdlen+1] == '\0')) {
/* Assume this is a cygwin path */
outpath = (char*)malloc(pathlen+1); /* conservative */
if(outpath == NULL) return NULL;
outpath[0] = path[cdlen];
if(outpath == NULL) goto done;
outpath[0] = path[cdlen]; /* drive letter */
outpath[1] = ':';
strcpy(&outpath[2],&path[cdlen+1]);
if(strlen(outpath) == 2)
@ -99,12 +110,31 @@ NCpathcvt(const char* path)
goto done;
slashtrans:
/* In all #1 or #2 cases, translate '/' -> '\\' */
/* In order to help debugging, and if not using MSC_VER or MINGW,
convert back slashes to forward, else convert forward to back
*/
p = outpath;
/* In all #1 or #2 cases, translate '/' -> '\\' */
for(;*p;p++) {
if(*p == '/') {*p = '\\';}
}
#ifdef PATHFORMAT
#ifndef _MSC_VER
p = outpath;
/* Convert '\' back to '/' */
for(;*p;p++) {
if(*p == '\\') {*p = '/';}
}
}
#endif /*!_MSC_VER*/
#endif /*PATHFORMAT*/
done:
if(pathdebug) {
fprintf(stderr,"XXXX: inpath=|%s| outpath=|%s|\n",
path?path:"NULL",outpath?outpath:"NULL");
fflush(stderr);
}
return outpath;
}
@ -120,8 +150,6 @@ NCfopen(const char* path, const char* flags)
{
FILE* f = NULL;
char* cvtname = NCpathcvt(path);
fprintf(stderr,"XXXX: path=|%s| cvtpath=|%s|\n",path,cvtname?cvtname:"null");
fflush(stderr);
if(cvtname == NULL) return NULL;
f = fopen(cvtname,flags);
free(cvtname);
@ -133,10 +161,8 @@ int
NCopen3(const char* path, int flags, int mode)
{
int fd = -1;
fprintf(stderr,"XXXX: path=|%s|\n",path);
fflush(stderr);
char* cvtname = NCpathcvt(path);
fprintf(stderr,"XXXX: path=|%s| cvtpath=|%s|\n",path,cvtname?cvtname:"null");
fflush(stderr);
if(cvtname == NULL) return -1;
fd = open(cvtname,flags,mode);

View File

@ -19,6 +19,9 @@
#define NCURIDEBUG
/* Extra debug info */
#undef NCXDEBUG
#ifdef NCURIDEBUG
#define THROW(n) {ret=(n); goto done;}
#else
@ -314,10 +317,7 @@ ncuriparse(const char* uri0, NCURI** durip)
if(strlen(pp)==0)
{THROW(NCU_EUSRPWD);} /* we have empty password */
tmp.password = pp;
/* compress usr+pwd out of tmp.host */
rem = strlen(newhost);
memmove(tmp.host,newhost,rem);
tmp.host[rem] = EOFCHAR;
tmp.host = newhost;
}
/* Breakup host into host + port */
pp = tmp.host;

View File

@ -35,11 +35,13 @@ static Test TESTS[] = {
{"[dap4]http://localhost:8081/x#show=fetch&log","http://localhost:8081/x#dap4&show=fetch&log"},
/* suffix param tests with constraint*/
{"http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log","http://localhost:8081/x?dap4.ce=x#dap4&show=fetch&log"},
/* Test embedded user+pwd */
{"http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc",
"http://tiggeUser:tigge@localhost:8081/thredds/dodsC/restrict/testData.nc"},
/* Misc. */
{"http://localhost","http://localhost/"},
{"http:///x","http:///x"},
{"file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc","file:///home/osboxes/git/dap4/dap4_test/daptestfiles/test_anon_dim.2.syn#dap4&debug=copy&substratename=./results/test_anon_dim.2.syn.nc"},
{NULL,NULL}
};

View File

@ -12,7 +12,6 @@ Test the NCpathcvt
#include <string.h>
#include "ncwinpath.h"
#undef WINDEBUG
#undef VERBOSE
typedef struct Test {

View File

@ -70,6 +70,11 @@ libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
endif #USE_NETCDF4
if ISCYGWIN
# Force binary mode for file read/write
AM_LDFLAGS += -lbinmode
endif
# We need at least one source file
libnetcdf_la_SOURCES = nc_initialize.c
EXTRA_DIST=CMakeLists.txt

View File

@ -35,6 +35,11 @@ extern int NCP_initialize(void);
extern int NCP_finalize(void);
#endif
#ifdef _MSC_VER
#include <io.h>
#include <fcntl.h>
#endif
int NC_argc = 1;
char* NC_argv[] = {"nc_initialize",NULL};
@ -59,6 +64,11 @@ nc_initialize()
NC_initialized = 1;
NC_finalized = 0;
#ifdef _MSC_VER
/* Force binary mode */
_set_fmode(_O_BINARY);
#endif
/* Do general initialization */
if((stat = NCDISPATCH_initialize())) goto done;

View File

@ -1113,7 +1113,7 @@ NC3_open(const char * path, int ioflags,
#if defined(LOCKNUMREC) /* && _CRAYMPP */
if (status = NC_init_pe(nc3, basepe)) {
return status;
goto unwind_alloc;
}
#else
/*
@ -1121,9 +1121,11 @@ NC3_open(const char * path, int ioflags,
*/
if(basepe != 0) {
if(nc3) free(nc3);
return NC_EINVAL;
status = NC_EINVAL;
goto unwind_alloc;
}
#endif
status = ncio_open(path, ioflags, 0, 0, &nc3->chunk, parameters,
&nc3->nciop, NULL);
if(status)

View File

@ -25,10 +25,7 @@ extern int nc4_vararray_add(NC_GRP_INFO_T *grp,
#ifdef USE_HDF4
#include <mfhdf.h>
#endif
#ifdef USE_DISKLESS
#include <hdf5_hl.h>
#endif
/* When we have open objects at file close, should
we log them or print to stdout. Default is to log
@ -302,9 +299,7 @@ nc_check_for_hdf(const char *path, int flags, void* parameters, int *hdf_file)
MPI_Info info = MPI_INFO_NULL;
#endif
int inmemory = ((flags & NC_INMEMORY) == NC_INMEMORY);
#ifdef USE_DISKLESS
NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
#endif
#ifdef USE_PARALLEL4
if(use_parallel) {
@ -602,15 +597,15 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
/* Check the cmode for validity. */
if((cmode & ILLEGAL_CREATE_FLAGS) != 0)
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Cannot have both */
if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Currently no parallel diskless io */
if((cmode & (NC_MPIIO | NC_MPIPOSIX)) && (cmode & NC_DISKLESS))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
#ifndef USE_PARALLEL_POSIX
/* If the HDF5 library has been compiled without the MPI-POSIX VFD, alias
@ -636,8 +631,10 @@ NC4_create(const char* path, int cmode, size_t initialsz, int basepe,
LOG((2, "cmode after applying default format: 0x%x", cmode));
nc_file->int_ncid = nc_file->ext_ncid;
res = nc4_create_file(nc_file->path, cmode, comm, info, nc_file);
res = nc4_create_file(path, cmode, comm, info, nc_file);
done:
return res;
}
@ -2231,9 +2228,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
int retval;
NC_HDF5_FILE_INFO_T* nc4_info = NULL;
int inmemory = ((mode & NC_INMEMORY) == NC_INMEMORY);
#ifdef USE_DISKLESS
NC_MEM_INFO* meminfo = (NC_MEM_INFO*)parameters;
#endif
#ifdef USE_PARALLEL4
NC_MPI_INFO* mpiinfo = (NC_MPI_INFO*)parameters;
int comm_duped = 0; /* Whether the MPI Communicator was duplicated */
@ -2845,11 +2840,11 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
/* Check the mode for validity */
if((mode & ILLEGAL_OPEN_FLAGS) != 0)
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Cannot have both */
if((mode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
#ifndef USE_PARALLEL_POSIX
/* If the HDF5 library has been compiled without the MPI-POSIX VFD, alias
@ -2864,7 +2859,7 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
/* Figure out if this is a hdf4 or hdf5 file. */
if ((res = nc_check_for_hdf(path, use_parallel, parameters, &hdf_file)))
return res;
goto done;
/* Depending on the type of file, open it. */
nc_file->int_ncid = nc_file->ext_ncid;
@ -2872,12 +2867,13 @@ NC4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
res = nc4_open_file(path, mode, parameters, nc_file);
#ifdef USE_HDF4
else if (hdf_file == NC_HDF4_FILE && inmemory)
return NC_EDISKLESS;
{res = NC_EDISKLESS; goto done;}
else if (hdf_file == NC_HDF4_FILE)
res = nc4_open_hdf4_file(path, mode, nc_file);
#endif /* USE_HDF4 */
else
assert(0); /* should never happen */
assert(0); /* should never happen */
done:
return res;
}

View File

@ -102,6 +102,11 @@ nc4_check_name(const char *name, char *norm_name)
retval = nc_utf8_normalize((const unsigned char *)name,(unsigned char**)&temp);
if(retval != NC_NOERR)
return retval;
if( strlen(temp) > NC_MAX_NAME )
{
free(temp);
return NC_EMAXNAME;
}
strcpy(norm_name, temp);
free(temp);

View File

@ -9,6 +9,7 @@
#include <mpi.h>
#include "nc.h"
#include "ncdispatch.h"
/* Must follow netcdf.h */
#include <pnetcdf.h>
@ -50,15 +51,15 @@ NCP_create(const char *path, int cmode,
/* Check the cmode for only valid flags*/
if(cmode & ~LEGAL_CREATE_FLAGS)
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Cannot have both MPIO flags */
if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Cannot have both NC_64BIT_OFFSET & NC_64BIT_DATA */
if((cmode & (NC_64BIT_OFFSET|NC_64BIT_DATA)) == (NC_64BIT_OFFSET|NC_64BIT_DATA))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
default_format = nc_get_default_format();
/* if (default_format == NC_FORMAT_CLASSIC) then we respect the format set in cmode */
@ -72,14 +73,17 @@ NCP_create(const char *path, int cmode,
}
/* No MPI environment initialized */
if (mpidata == NULL) return NC_ENOPAR;
if (mpidata == NULL)
{res = NC_ENOPAR; goto done;}
comm = ((NC_MPI_INFO *)mpidata)->comm;
info = ((NC_MPI_INFO *)mpidata)->info;
/* Create our specific NCP_INFO instance */
nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
if(nc5 == NULL) return NC_ENOMEM;
if(nc5 == NULL)
{res = NC_ENOMEM; goto done;}
/* Link nc5 and nc */
NCP_DATA_SET(nc,nc5);
@ -97,9 +101,11 @@ NCP_create(const char *path, int cmode,
*/
/* PnetCDF recognizes the flags below for create and ignores NC_LOCK and NC_SHARE */
cmode &= (NC_WRITE | NC_NOCLOBBER | NC_SHARE | NC_64BIT_OFFSET | NC_64BIT_DATA);
res = ncmpi_create(comm, path, cmode, info, &(nc->int_ncid));
if(res && nc5 != NULL) free(nc5); /* reclaim allocated space */
done:
return res;
}
@ -116,16 +122,15 @@ NCP_open(const char *path, int cmode,
/* Check the cmode for only valid flags*/
if(cmode & ~LEGAL_OPEN_FLAGS)
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Cannot have both MPIO flags */
if((cmode & (NC_MPIIO|NC_MPIPOSIX)) == (NC_MPIIO|NC_MPIPOSIX))
return NC_EINVAL;
{res = NC_EINVAL; goto done;}
/* Appears that this comment is wrong; allow 64 bit offset*/
/* Cannot have 64 bit offset flag */
/* if(cmode & (NC_64BIT_OFFSET)) return NC_EINVAL; */
/* if(cmode & (NC_64BIT_OFFSET)) {res = NC_EINVAL; goto done;} */
if(mpidata != NULL) {
comm = ((NC_MPI_INFO *)mpidata)->comm;
info = ((NC_MPI_INFO *)mpidata)->info;
@ -145,7 +150,7 @@ NCP_open(const char *path, int cmode,
/* Create our specific NCP_INFO instance */
nc5 = (NCP_INFO*)calloc(1,sizeof(NCP_INFO));
if(nc5 == NULL) return NC_ENOMEM;
if(nc5 == NULL) {res = NC_ENOMEM; goto done;}
/* Link nc5 and nc */
NCP_DATA_SET(nc,nc5);
@ -157,7 +162,7 @@ NCP_open(const char *path, int cmode,
res = ncmpi_begin_indep_data(nc->int_ncid);
nc5->pnetcdf_access_mode = NC_INDEPENDENT;
}
done:
return res;
}

View File

@ -3,7 +3,7 @@
See COPYRIGHT file for copying and redistribution conditions.
This is part of netCDF.
This program also takes a long time to run - it writes some data in
a very large file, and then reads it all back to be sure it's
correct.
@ -47,11 +47,13 @@ main(int argc, char **argv) {
int n_dim;
#define NUMRECS 2
#define I_LEN 5
#if 0
#define J_LEN 214700000
#endif
#define J_LEN 500000000
#define I_LEN 4106
//#define I_LEN 5
//#if 0
//#define J_LEN 214700000
//#endif
//#define J_LEN 500000000
#define J_LEN 1023
#define K_LEN 1023
#define N_LEN 2
@ -157,7 +159,7 @@ main(int argc, char **argv) {
check_err(stat,__LINE__,__FILE__);
{ /* read var1 */
/*static float avar1[J_LEN];*/
static float *avar1 = NULL;
avar1 = (float*)malloc(sizeof(float)*J_LEN);
@ -172,11 +174,11 @@ main(int argc, char **argv) {
avar1_start[1] = i;
stat = nc_get_vara_float(ncid, var1_id, avar1_start, avar1_count, avar1);
check_err(stat,__LINE__,__FILE__);
for(j=0; j<J_LEN; j++)
for(j=0; j<J_LEN; j++)
{
if (avar1[j] != (float)(j + (rec + 1) * i)) {
printf("Error on read, var1[%d, %d, %d] = %g wrong, "
"should be %g !\n", rec, i, j, avar1[j], (float) (j + (rec + 1)* i));
"should be %g !\n", rec, i, j, avar1[j], (float) (j + (rec + 1)* i));
return 1;
}
}

View File

@ -28,6 +28,7 @@ IF(ENABLE_TESTS)
BUILD_BIN_TEST(findtestserver)
IF(BUILD_UTILITIES)
add_sh_test(ncdap tst_ber)
add_sh_test(ncdap tst_remote3)
# not yet add_sh_test(ncdap tst_hyrax)
ENDIF(BUILD_UTILITIES)

View File

@ -8,6 +8,9 @@
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
LDADD = ${top_builddir}/liblib/libnetcdf.la
AM_CPPFLAGS += -I$(top_srcdir)/liblib
AM_CPPFLAGS += -DTOPSRCDIR=${abs_top_srcdir}
@ -34,7 +37,7 @@ check_PROGRAMS += findtestserver
findtestserver_SOURCES = findtestserver.c
if BUILD_UTILITIES
TESTS += tst_remote3.sh tst_formatx.sh
TESTS += tst_ber.sh tst_remote3.sh tst_formatx.sh
endif
TESTS += test_partvar testurl.sh
@ -79,7 +82,7 @@ EXTRA_DIST = tst_ncdap3.sh \
tst_longremote3.sh \
tst_ncdap.sh tst_ncdap_shared.sh tst_remote.sh \
t_dap.c CMakeLists.txt tst_formatx.sh testauth.sh testurl.sh \
t_ncf330.c
t_ncf330.c tst_ber.sh
CLEANFILES = test_varm3 test_cvt3 results/*.dmp results/*.das results/*.dds datadds* t_dap3a test_nstride_cached *.exe
@ -89,9 +92,6 @@ t_dap3a.c: t_dap.c
echo "#define NETCDF3ONLY" > ./t_dap3a.c
cat t_dap.c >> t_dap3a.c
t_dap4a.c: t_dap.c
cat t_dap.c >> ./t_dap4a.c
# One last thing
BUILT_SOURCES = .dodsrc

View File

@ -307,6 +307,7 @@ int main()
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
exit(1);
}
nc_close(ncid);
return 0;
}

View File

@ -308,6 +308,7 @@ int main()
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
exit(1);
}
nc_close(ncid);
return 0;
}

View File

@ -307,6 +307,7 @@ int main()
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
exit(1);
}
nc_close(ncid);
return 0;
}

View File

@ -251,6 +251,7 @@ main()
}
printf("*** %s: stride case 3\n",(fail?"Fail":"Pass"));
nc_close(ncid);
return fail;
}

View File

@ -3,6 +3,9 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Enable if using localhost
LOCAL=1
RCEMBED=1
RCLOCAL=1
RCHOME=1
@ -40,10 +43,13 @@ fi
BASICCOMBO="tiggeUser:tigge"
BADCOMBO="tiggeUser:xxxxx"
URLSERVER="remotetest.unidata.ucar.edu"
#http://remotetest.unidata.ucar.edu/thredds/dodsC/restrict/testData.nc.html
URLPATH="thredds/dodsC/restrict/testData.nc"
URLPATH="thredds/dodsC/testRestrictedDataset/testData2.nc"
PROTO=http
if test "x$LOCAL" = x ; then
URLSERVER="remotetest.unidata.ucar.edu"
else
URLSERVER="localhost:8081"
fi
# See if we need to override
if test "x$URS" != "x" ; then

19
ncdap_test/tst_ber.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
export SETX=1
#export NCPATHDEBUG=1
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
F="ber-2002-10-01.nc"
EXPECTED="${srcdir}/expected3"
URL='[log][cache]file://'
URL="${URL}${srcdir}/testdata3/$F"
rm -f ./tmp
${NCDUMP} "${URL}" | sed 's/\\r//g' > ./tmp
diff -w ${EXPECTED}/$F.dmp ./tmp
#cleanup
rm -f ./tmp
exit

Some files were not shown because too many files have changed in this diff Show More