mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-04-06 18:00:24 +08:00
add cdmremote skeleton code
This commit is contained in:
parent
6ecbe1209f
commit
f7e41dde66
@ -100,6 +100,11 @@ if BUILD_LIBCF
|
||||
LIBCF=libcf
|
||||
endif
|
||||
|
||||
# Build libcdmr
|
||||
if BUILD_CDMREMOTE
|
||||
LIBCDMR=libcdmr
|
||||
endif
|
||||
|
||||
#WIN32=win32
|
||||
|
||||
# This is the list of subdirs for which Makefiles will be constructed
|
||||
@ -111,13 +116,13 @@ endif
|
||||
# If using dispatch, then the order is different
|
||||
if BUILD_SEPARATE_FORTRAN
|
||||
SUBDIRS = include $(UDUNITS) $(DISPATCHDIR) $(OCLIB) $(F90_DIR) \
|
||||
$(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) \
|
||||
$(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) $(LIBCDMR) \
|
||||
${ASSEMBLEDIR} $(V2_TEST) $(NCGEN3) $(NCGEN) $(NCDUMP) $(F77_TEST) \
|
||||
${CXX_DIR} $(CXX4) $(NC_TEST_DIR) $(NC_TEST4) $(NCDAPTESTDIR) man4 \
|
||||
$(EXAMPLES) $(WIN32) $(LIBCF)
|
||||
else
|
||||
SUBDIRS = include $(UDUNITS) $(DISPATCHDIR) $(OCLIB) $(F90_DIR) \
|
||||
$(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) \
|
||||
$(F77_DIR) $(LIBSRC_DIR) $(LIBSRC4_DIR) $(NCDAP3) $(NCDAP4) $(LIBCDMR) \
|
||||
${ASSEMBLEDIR} $(V2_TEST) $(NCGEN3) $(NCGEN) $(NCDUMP) $(F77_TEST) \
|
||||
${CXX_DIR} $(CXX4) $(NC_TEST_DIR) $(NC_TEST4) $(NCDAPTESTDIR) man4 \
|
||||
$(EXAMPLES) $(WIN32) $(LIBCF)
|
||||
|
98
configure.ac
98
configure.ac
@ -317,15 +317,16 @@ AC_ARG_ENABLE([logging],
|
||||
test "x$enable_logging" = xyes || enable_logging=no
|
||||
AC_MSG_RESULT([$enable_logging])
|
||||
|
||||
# Figure out if DAP support should be enabled.
|
||||
# Figure out if curl support should be enabled.
|
||||
# The primary goal is to first locate curl-config
|
||||
# or the curl library location
|
||||
# The rules we implement are applied in order:
|
||||
# 1. no: if --disable-dap is set
|
||||
# 2. no: if curl library cannot be located
|
||||
# 3. yes: if --enable-dap is set
|
||||
# 3. yes: if --enable-dap || --enable-cdmremote is set
|
||||
# 4. yes: if neither --enable-dap nor --disable-dap is specified
|
||||
# and the curl library can be located
|
||||
# Note that for now, cdmremote must be explicitly enabled
|
||||
|
||||
# Capture the state of the --enable-dap flag
|
||||
AC_MSG_CHECKING([whether DAP client is to be built])
|
||||
@ -335,8 +336,24 @@ AC_ARG_ENABLE([dap],
|
||||
test "x$enable_dap" = xno || enable_dap=yes
|
||||
AC_MSG_RESULT($enable_dap)
|
||||
|
||||
# If --disable-dap, then make no attempt to locate curl
|
||||
if test "$enable_dap" = yes ; then
|
||||
# Capture the state of the --enable-cdmremote flag
|
||||
AC_MSG_CHECKING([whether cdmremote client is to be built])
|
||||
AC_ARG_ENABLE([cdmremote],
|
||||
[AS_HELP_STRING([--enable-cdmremote],
|
||||
[build with cdmremote client support.])])
|
||||
test "x$enable_cdmremote" = xyes || enable_cdmremote=no
|
||||
# CDMREMOTE requires netCDF-4
|
||||
if test "x$enable_netcdf_4" = "xno" ; then enable_cdmremote=no ; fi
|
||||
AC_MSG_RESULT($enable_cdmremote)
|
||||
|
||||
# If --disable-dap && cdmremote , then make no attempt to locate curl
|
||||
if test "x$enable_dap" = "xyes" -o "x$enable_cdmremote" = "xyes" ; then
|
||||
require_curl=yes
|
||||
else
|
||||
require_curl=no
|
||||
fi
|
||||
|
||||
if test "$require_curl" = yes ; then
|
||||
|
||||
# Try to locate curl
|
||||
curlsrc=
|
||||
@ -390,25 +407,17 @@ if test "x$curlsrc" = "x" ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# compute curl values
|
||||
if test -n "$with_curl_config" -a -z "$with_curl" ; then
|
||||
# pretend that --with-curl-config was specified
|
||||
with_curl=`$with_curl_config --prefix`
|
||||
fi
|
||||
|
||||
# Compute the curl flags and libs
|
||||
if test -n "$with_curl_config" ; then
|
||||
curl_cflags=`$with_curl_config --cflags`
|
||||
curl_libs=`$with_curl_config --libs`
|
||||
curl_dir="$with_curl"
|
||||
curl_dir=`$with_curl_config --prefix`
|
||||
elif test -n "$with_curl" ; then
|
||||
curl_libs="-L$with_curl/lib -lcurl"
|
||||
curl_cflags="-I$with_curl/include"
|
||||
curl_dir="$with_curl"
|
||||
else
|
||||
curl_cflags=-lcurl
|
||||
curl_libs=
|
||||
curl_dir=
|
||||
AC_MSG_ERROR([Cannot locate neither curl-config or a curl directory])
|
||||
fi
|
||||
|
||||
# CURLOPT_KEYPASSWD is not defined until curl version 7.16.4
|
||||
@ -439,13 +448,13 @@ if test $havekeypasswd -eq 1; then
|
||||
AC_DEFINE([HAVE_CURLOPT_KEYPASSWD], [1], [CURLOPT_KEYPASSWD is defined])
|
||||
fi
|
||||
|
||||
else #!enable_dap
|
||||
else #!require_curl
|
||||
|
||||
curl_cflags=""
|
||||
curl_libs=""
|
||||
curl_dir=""
|
||||
|
||||
fi #enable_dap
|
||||
fi #require_curl
|
||||
|
||||
AC_SUBST([CURL_CFLAGS],[${curl_cflags}])
|
||||
AC_SUBST([CURL_FCFLAGS],[${curl_cflags}])
|
||||
@ -453,21 +462,15 @@ AC_SUBST([CURL_FFLAGS],[${curl_cflags}])
|
||||
AC_SUBST([CURL_LIBS],[${curl_libs}])
|
||||
AC_SUBST([CURLDIR],[${curl_dir}])
|
||||
|
||||
# If enable_dap is true but there is no curl, then complain
|
||||
# If curl is required but there is no curl, then complain
|
||||
if test -z "$curlsrc" ; then
|
||||
if test "x$enable_dap" = "xyes" ; then
|
||||
AC_MSG_NOTICE("--enable-dap requires curl library; disabling dap support")
|
||||
if test "x$require_curl" = "xyes" ; then
|
||||
AC_MSG_NOTICE([libcurl not found; disabling dap and cdmremote support])
|
||||
fi
|
||||
enable_dap=no
|
||||
enable_cdmremote=no
|
||||
fi
|
||||
|
||||
if test "x$enable_dap" = xyes; then
|
||||
AC_DEFINE([USE_DAP], [1], [if true, build DAP Client])
|
||||
AC_DEFINE([ENABLE_DAP], [1], [if true, build DAP Client])
|
||||
fi
|
||||
if test "x$enable_dap_remote_tests" = xyes; then
|
||||
AC_DEFINE([ENABLE_DAP_REMOTE_TESTS], [1], [if true, do remote tests])
|
||||
fi
|
||||
|
||||
# Default is now to always do the short remote tests
|
||||
AC_MSG_CHECKING([whether dap remote testing should be enabled (default on)])
|
||||
@ -480,6 +483,19 @@ if test "x$enable_dap" = "xno" ; then
|
||||
fi
|
||||
AC_MSG_RESULT($enable_dap_remote_tests)
|
||||
|
||||
# Set the config.h flags
|
||||
if test "x$enable_dap" = xyes; then
|
||||
AC_DEFINE([USE_DAP], [1], [if true, build DAP Client])
|
||||
AC_DEFINE([ENABLE_DAP], [1], [if true, build DAP Client])
|
||||
fi
|
||||
|
||||
if test "x$enable_dap_remote_tests" = xyes; then
|
||||
AC_DEFINE([ENABLE_DAP_REMOTE_TESTS], [1], [if true, do remote tests])
|
||||
fi
|
||||
|
||||
if test "x$enable_cdmremote" = xyes; then
|
||||
AC_DEFINE([USE_CDMREMOTE], [1], [if true, build CDMREMOTE Client])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether the time-consuming dap tests should be enabled (default off)])
|
||||
AC_ARG_ENABLE([dap-long-tests],
|
||||
@ -783,6 +799,7 @@ if test "x$nc_build_c" = xno -a x$enable_separate_fortran != xyes; then
|
||||
AC_MSG_ERROR([If the C API is disabled, you must use --enable-separate-fortran.])
|
||||
fi
|
||||
|
||||
|
||||
## Does the user want to allow UTF8 characters
|
||||
#AC_MSG_CHECKING([whether UTF8 is allowed in identifiers])
|
||||
#AC_ARG_ENABLE([utf8],
|
||||
@ -1259,11 +1276,6 @@ LDFLAGS=${OLD_LDFLAGS}
|
||||
LIBS=${OLD_LIBS}
|
||||
CPPFLAGS=${OLD_CPPFLAGS}
|
||||
|
||||
# Do Renaming if netcdf4 or dap support is enabled
|
||||
if test "x$enable_netcdf_4" = xyes -o "x$enable_dap" = xyes ; then
|
||||
AC_DEFINE([USE_RENAMEV3], [1], [if true, build libsrc code with renamed API functions])
|
||||
fi
|
||||
|
||||
# No logging for netcdf-3.
|
||||
if test "x$enable_netcdf_4" = xno; then
|
||||
enable_logging=no
|
||||
@ -1299,6 +1311,7 @@ AM_CONDITIONAL(USE_HDF4_FILE_TESTS, [test x$enable_hdf4_file_tests = xyes])
|
||||
AM_CONDITIONAL(USE_RENAMEV3, [test x$enable_netcdf_4 = xyes -o x$enable_dap = xyes])
|
||||
AM_CONDITIONAL(USE_PNETCDF, [test x$enable_pnetcdf = xyes])
|
||||
AM_CONDITIONAL(USE_DISPATCH, [test x$enable_dispatch = xyes])
|
||||
AM_CONDITIONAL(BUILD_CDMREMOTE, [test "x$enable_cdmremote" = xyes]) # Alias
|
||||
|
||||
# If the machine doesn't have a long long, and we want netCDF-4, then
|
||||
# we've got problems!
|
||||
@ -1441,26 +1454,26 @@ AC_CONFIG_SUBDIRS([udunits libcf])
|
||||
# Define the -L flags and libs for external libraries
|
||||
EXTERN_LDFLAGS=""
|
||||
# Define the -I flags for external libraries
|
||||
EXTERN_CFLAGS=""
|
||||
EXTERN_CPPFLAGS=""
|
||||
|
||||
# Add all libraries even if shared is enabled
|
||||
if test "x$enable_netcdf_4" = xyes ; then
|
||||
if test "x$HDF5DIR" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -L$HDF5DIR/lib"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} -I$HDF5DIR/include"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} -I$HDF5DIR/include"
|
||||
fi
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -lhdf5_hl -lhdf5"
|
||||
if test "x$enable_hdf4" = xyes; then
|
||||
if test "x$HDF4DIR" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -L$HDF4DIR/lib"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} -I$HDF4DIR/include"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} -I$HDF4DIR/include"
|
||||
fi
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -lmfhdf -ldf"
|
||||
fi
|
||||
if test "x$enable_pnetcdf" = xyes; then
|
||||
if test "x$PNETCDFDIR" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -L$PNETCDFDIR/lib"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} -I$PNETCDFDIR/include"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} -I$PNETCDFDIR/include"
|
||||
fi
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -lpnetcdf"
|
||||
fi
|
||||
@ -1469,19 +1482,19 @@ fi # netcdf-4
|
||||
if test "x$enable_netcdf_4" = xyes -o "x$enable_dap" = xyes ; then
|
||||
if test "x$ZLIBDIR" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -L$ZLIBDIR/lib"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} -I$ZLIBDIR/include"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} -I$ZLIBDIR/include"
|
||||
fi
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -lz"
|
||||
if test "x$SZLIBDIR" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} -L$SZLIBDIR/lib -lsz"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} -I$SZLIBDIR/include"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} -I$SZLIBDIR/include"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_dap" = xyes ; then
|
||||
if test "x$curl_libs" != x ; then
|
||||
EXTERN_LDFLAGS="${EXTERN_LDFLAGS} $curl_libs"
|
||||
EXTERN_CFLAGS="${EXTERN_CFLAGS} $curl_cflags"
|
||||
EXTERN_CPPFLAGS="${EXTERN_CPPFLAGS} $curl_cflags"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1502,11 +1515,13 @@ xsolaris*)
|
||||
;;
|
||||
*);;
|
||||
esac
|
||||
AC_SUBST(EXTERN_CFLAGS,[$EXTERN_CFLAGS])
|
||||
# Alias
|
||||
EXTERN_CFLAGS="$EXTERN_CPPFLAGS"
|
||||
AC_SUBST(EXTERN_CPPFLAGS,[$EXTERN_CPPFLAGS])
|
||||
AC_SUBST(EXTERN_LDFLAGS,[$EXTERN_LDFLAGS])
|
||||
AC_SUBST(EXTERN_CPPFLAGS,[$EXTERN_CFLAGS])
|
||||
AC_SUBST(EXTERN_CFLAGS,[$EXTERN_CFLAGS])
|
||||
|
||||
AC_MSG_NOTICE(CFLAGS for External libraries: ${EXTERN_CFLAGS})
|
||||
AC_MSG_NOTICE(CPPFLAGS for External libraries: ${EXTERN_CPPFLAGS})
|
||||
AC_MSG_NOTICE(LDFLAGS for External libraries: ${EXTERN_LDFLAGS})
|
||||
|
||||
##################################################
|
||||
@ -1558,6 +1573,7 @@ AC_CONFIG_FILES([Makefile
|
||||
oc/Makefile
|
||||
libncdap3/Makefile
|
||||
libncdap4/Makefile
|
||||
libcdmr/Makefile
|
||||
libdispatch/Makefile
|
||||
liblib/Makefile
|
||||
ncdap_test/Makefile
|
||||
|
165
libcdmr/Make0
Executable file
165
libcdmr/Make0
Executable file
@ -0,0 +1,165 @@
|
||||
#NCLIB=../libsrc4/.libs/libnetcdf.a
|
||||
NCLIB=../liblib/.libs/libnetcdf.a
|
||||
#HDF5DIR = /upc/share/stdinstall/local/spock
|
||||
HDF5DIR = /machine/local
|
||||
HDFLIBS=${HDF5DIR}/lib/libhdf5_hl.a ${HDF5DIR}/lib/libhdf5.a
|
||||
NCINCL=-I../libsrc4 -I${HDF5DIR}/include -I${NCDAP3DIR}
|
||||
#CURLLIB=-L/opt/csw/lib -lcurl
|
||||
CURLLIB=-L/opt/csw/lib -lcurl -lidn -lssl -lcrypto -llber -lldap -lnsl
|
||||
CURLINCL=-I/opt/csw/include
|
||||
RPCLIB=-lnsl
|
||||
ZLIB=-L/opt/csw/lib -lz
|
||||
TESTURL=file:///upc/share/dmh/nc/netcdf-3/ncdap_test/testdata3
|
||||
VALGRIND=valgrind --leak-check=full
|
||||
|
||||
|
||||
OCLIB=../libncdap3/oc/.libs/liboc.a
|
||||
OCINCL=-I../libncdap3/oc
|
||||
|
||||
OTHERLIBS=-lm
|
||||
|
||||
# Might want to specify a particular C compiler with flags
|
||||
#CC=cc
|
||||
CFLAGS=-Wall -DHAVE_CONFIG_H
|
||||
#CFLAGS=-DHAVE_CONFIG_H
|
||||
|
||||
GFLAGS=-g
|
||||
#############################################
|
||||
|
||||
LIBS=${NCLIB} ${CURLLIB} ${HDFLIBS} ${ZLIB} ${OTHERLIBS} ${RPCLIB}
|
||||
INCL=-I. -I.. -I../include ${OCINCL} ${NCINCL} ${CURLINCL}
|
||||
|
||||
TESTLIBS=${LIBS}
|
||||
TESTINCL=${INCL}
|
||||
|
||||
##################################################
|
||||
|
||||
SRC=\
|
||||
ncdap4.c \
|
||||
getvar4.c \
|
||||
dispatch4.c \
|
||||
dapdispatch4.c
|
||||
|
||||
HDRS=\
|
||||
ncdap4.h \
|
||||
dispatch4.h \
|
||||
dapdispatch4.c
|
||||
|
||||
OBJ=${SRC:%.c=%.o}
|
||||
|
||||
ALLSRC=${SRC} ${HDRS}
|
||||
|
||||
DRNOLIB=libncdap4.a
|
||||
|
||||
all:: ncd
|
||||
|
||||
##################################################
|
||||
|
||||
#${EXE}: ${DRNOLIB} main.c
|
||||
# ${CC} ${INCL} ${GFLAGS} -c main.c
|
||||
# ${CC} -o ${EXE} main.o ${DRNOLIB} ${OCLIB} ${LIBS}
|
||||
|
||||
${DRNOLIB}:
|
||||
cp .libs/${DRNOLIB} .
|
||||
|
||||
#${DRNOLIB}: ${OBJ}
|
||||
# ar r ${DRNOLIB} ${OBJ}
|
||||
|
||||
${OBJ}: ${SRC} ${HDRS}
|
||||
${CC} ${CFLAGS} ${GFLAGS} -c ${INCL} ${SRC}
|
||||
|
||||
##################################################
|
||||
clean::
|
||||
rm -f *.o *.exe ${EXE} ${DRNOLIB} ncdump.exe
|
||||
rm -fr *.tab.c *.tab.h *.output
|
||||
rm -f *.stackdump
|
||||
|
||||
##################################################
|
||||
# ncd
|
||||
NCDUMPC=../ncdump/dumplib.c ../ncdump/indent.c ../ncdump/ncdump.c ../ncdump/nctime.c ../ncdump/vardata.c
|
||||
NCDUMPH=../ncdump/cdl.h ../ncdump/dumplib.h ../ncdump/indent.h ../ncdump/isnan.h ../ncdump/ncdump.h ../ncdump/nctime.h ../ncdump/vardata.h
|
||||
NCDUMPOBJ=${NCDUMPC:../ncdump/%.c=%.o}
|
||||
|
||||
#${NCDUMPC} ${NCDUMPH} ${NCLIB}
|
||||
ncd::
|
||||
cd ../libncdap3; make
|
||||
cd ../libsrc; make
|
||||
cd ../libncdap4; make
|
||||
cd ../libsrc4; make
|
||||
${CC} ${CFLAGS} ${GFLAGS} -c ${INCL} ${NCDUMPC}
|
||||
${CC} -o ncd ${GFLAGS} ${NCDUMPOBJ} ${NCLIB} ${CURLLIB} ${HDFLIBS} ${OTHERLIBS}
|
||||
|
||||
##################################################
|
||||
ALLTESTS=
|
||||
|
||||
tests::
|
||||
rm -fr results
|
||||
mkdir results
|
||||
for t in ${ALLTESTS} ; do (\
|
||||
echo "-------------------------" ; \
|
||||
echo "$${t}:" ; \
|
||||
echo "-------------------------"; \
|
||||
./ncd "${TESTPARAMS}${TESTURL}/$${t}${TESTCONS}" > results/$${t}.dmp ; \
|
||||
echo; \
|
||||
) done
|
||||
|
||||
td:: ${TESTSRC} ${TEST}.c
|
||||
${CC} ${CFLAGS} ${TESTINCL} ${GFLAGS} -c ${TEST}.c ${TESTSRC}
|
||||
${CC} -o ${TEST}.exe ${TEST}.o ${TESTOBJ} ${TESTLIBS}
|
||||
./${TEST}.exe -v ${TEST}
|
||||
|
||||
URL=${TESTPARAMS}${TESTURL}/${TEST}${TESTCONS}
|
||||
|
||||
t:: ${EXE}
|
||||
${VALGRIND} ./${EXE} -v ${TESTDEBUG} "${URL}"
|
||||
|
||||
cpp::
|
||||
rm -f junki
|
||||
cc -E -DHAVE_CONFIG_H -I. -I.. -I../fortran -I../libsrc -I../libncdap/oc ${GFLAGS} drno.c >junk
|
||||
|
||||
cvt::
|
||||
rm -f tmp1 tmp2
|
||||
cp translation.html tmp1
|
||||
sed -e 's|[&]gt;|>|g' -e 's|[&]lt;|<|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|‑|-|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<p>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<html>||g' -e 's|</html>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<body>||g' -e 's|</body>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<ol>|@enumerate|g' -e 's|</ol>|@end enumerate|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<ul>|@itemize|g' -e 's|</ul>|@end itemize|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<li>|@item |g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<pre>|@verbatim|g' -e 's|</pre>|@end verbatim|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<a[^>]*>||g' -e 's|</a>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h1>|@subsection |g' -e 's|</h1>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h2>|@subsubsection |g' -e 's|</h2>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h3>|@subsubsection |g' -e 's|</h3>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<table[^>]*>|@table @emph|g' -e 's|</table>|@end table|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<tr>|@item |g' -e 's|<td>| |g' -e 's|<th>| |g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
mv tmp1 ../man4/translation.texi
|
||||
rm -fr tmp1 tmp2
|
||||
scp translation.html conan:/content/staff/dmh/daptranslation.html
|
||||
|
||||
##################################################
|
||||
|
||||
v::
|
||||
gcc -g -c tst_cvt.c ${INCL}
|
||||
gcc -g -o tst_cvt tst_cvt.o ${LIBS}
|
||||
|
||||
i::
|
||||
cc -fPIC -g -c -I/tmp/install/${HOST}/include test_cvt.c
|
||||
cc -g -o v test_cvt.o -L/tmp/install/${HOST}/lib -lnetcdf -R/tmp/install/${HOST}/lib
|
55
libcdmr/Makefile.am
Executable file
55
libcdmr/Makefile.am
Executable file
@ -0,0 +1,55 @@
|
||||
## This is a automake file, part of Unidata's netCDF package.
|
||||
# Copyright 2010, see the COPYRIGHT file for more information.
|
||||
|
||||
# This builds the netcdf-4 version of the opendap client.
|
||||
|
||||
# $Id: Makefile.am,v 1.18 2010/05/29 18:45:47 dmh Exp $
|
||||
|
||||
DISTCLEANFILES =
|
||||
CLEANFILES =
|
||||
LDADD=
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
AM_LDFLAGS =
|
||||
|
||||
# CDMREMORE Sources
|
||||
SRC=curlwrap.c nccr.c nccrdispatch.c nccrgetvara.c nccrmeta.c \
|
||||
crdebug.c crutil.c
|
||||
|
||||
HDRS=curlwrap.h nccrconstraints.h nccrdispatch.h nccr.h \
|
||||
crdebug.h crutil.h
|
||||
|
||||
if BUILD_CDMREMOTE
|
||||
|
||||
noinst_LTLIBRARIES = libnccr.la
|
||||
|
||||
# Build convenience library
|
||||
libnccr_la_SOURCES = $(SRC) $(HDRS)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/libsrc4 \
|
||||
-I$(top_srcdir)/libsrc \
|
||||
-I$(top_srcdir)/libdispatch
|
||||
|
||||
AM_CPPFLAGS += -I${top_srcdir}/libdispatch @EXTERN_CPPFLAGS@
|
||||
|
||||
# Define the load libraries for stub3
|
||||
LDADD += ${top_builddir}/libcdmr/libnccr.la \
|
||||
${top_builddir}/libsrc4/libnetcdf4.la \
|
||||
${top_builddir}/libsrc/libnetcdf3.la \
|
||||
${top_builddir}/libdispatch/libdispatch.la
|
||||
|
||||
if BUILD_V2
|
||||
LDADD += ${top_builddir}/libdispatch/libnetcdf2.la
|
||||
endif # BUILD_V2
|
||||
|
||||
LDADD += @EXTERN_LDFLAGS@
|
||||
|
||||
# Add a trivial test case to check for undefined references
|
||||
check_PROGRAMS = t_cdmr
|
||||
TESTS = t_cdmr
|
||||
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
|
||||
t_cdmr_SOURCES = t_cdmr.c nccrstub.c
|
||||
CLEANFILES += t_cdmr
|
||||
|
||||
endif # BUILD_CDMREMOTE
|
||||
|
||||
|
42
libcdmr/crdebug.c
Normal file
42
libcdmr/crdebug.c
Normal file
@ -0,0 +1,42 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.c,v 1.9 2009/09/23 22:26:00 dmh Exp $
|
||||
*********************************************************************/
|
||||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nccr.h"
|
||||
|
||||
#ifdef CATCHERROR
|
||||
|
||||
/* Place breakpoint here to catch errors close to where they occur*/
|
||||
int
|
||||
nccrbreakpoint(int err) {return err;}
|
||||
|
||||
int
|
||||
nccrthrow(int err)
|
||||
{
|
||||
if(err == 0) return err;
|
||||
return dapbreakpoint(err);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
nccrpanic(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
if(fmt != NULL) {
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n" );
|
||||
va_end( args );
|
||||
} else {
|
||||
fprintf(stderr, "panic" );
|
||||
}
|
||||
fprintf(stderr, "\n" );
|
||||
fflush(stderr);
|
||||
return 0;
|
||||
}
|
||||
|
50
libcdmr/crdebug.h
Normal file
50
libcdmr/crdebug.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.h,v 1.33 2009/12/03 18:53:16 dmh Exp $
|
||||
*********************************************************************/
|
||||
#ifndef CRDEBUG_H
|
||||
#define CRDEBUG_H
|
||||
|
||||
#undef DEBUG
|
||||
#undef PARSEDEBUG
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Warning: setting CATCHERROR has significant performance impact */
|
||||
#undef CATCHERROR
|
||||
#ifdef DEBUG
|
||||
#undef CATCHERROR
|
||||
#define CATCHERROR
|
||||
#endif
|
||||
|
||||
/* Define the nc_log Levels */
|
||||
#define LOGNOTE 1
|
||||
#define LOGWARN 2
|
||||
#define LOGERR 3
|
||||
|
||||
#define PANIC(msg) assert(nccrpanic(msg));
|
||||
#define PANIC1(msg,arg) assert(nccrpanic(msg,arg));
|
||||
#define PANIC2(msg,arg1,arg2) assert(nccrpanic(msg,arg1,arg2));
|
||||
|
||||
#define ASSERT(expr) if(!(expr)) {PANIC(#expr);} else {}
|
||||
|
||||
extern int nccrpanic(const char* fmt, ...);
|
||||
|
||||
#define MEMCHECK(var,throw) {if((var)==NULL) return (throw);}
|
||||
|
||||
#ifdef CATCHERROR
|
||||
/* Place breakpoint on dapbreakpoint to catch errors close to where they occur*/
|
||||
#define THROW(e) nccrthrow(e)
|
||||
#define THROWCHK(e) (void)nccrthrow(e)
|
||||
|
||||
extern int nccrbreakpoint(int err);
|
||||
extern int nccrthrow(int err);
|
||||
#else
|
||||
#define THROW(e) (e)
|
||||
#define THROWCHK(e)
|
||||
#endif
|
||||
|
||||
#endif /*CRDEBUG_H*/
|
||||
|
5
libcdmr/crutil.c
Normal file
5
libcdmr/crutil.c
Normal file
@ -0,0 +1,5 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap3/common34.c,v 1.29 2010/05/25 13:53:02 ed Exp $
|
||||
*********************************************************************/
|
11
libcdmr/crutil.h
Normal file
11
libcdmr/crutil.h
Normal file
@ -0,0 +1,11 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef CRUTIL_H
|
||||
#define CRUTIL_H
|
||||
|
||||
#endif /*CRUTIL_H*/
|
452
libcdmr/curlwrap.c
Normal file
452
libcdmr/curlwrap.c
Normal file
@ -0,0 +1,452 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "nccr.h"
|
||||
#include "curlwrap.h"
|
||||
|
||||
static size_t WriteFileCallback(void*, size_t, size_t, void*);
|
||||
static size_t WriteMemoryCallback(void*, size_t, size_t, void*);
|
||||
|
||||
static char* combinecredentials(const char* user, const char* pwd);
|
||||
|
||||
struct Fetchdata {
|
||||
FILE* stream;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
/* Condition on libcurl version */
|
||||
#ifndef HAVE_CURLOPT_KEYPASSWD
|
||||
/* Set up an alias */
|
||||
#define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD
|
||||
#endif
|
||||
|
||||
/**************************************************/
|
||||
|
||||
long
|
||||
nc_fetchhttpcode(CURL* curl)
|
||||
{
|
||||
long httpcode;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
/* Extract the http code */
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&httpcode);
|
||||
if(cstat != CURLE_OK) httpcode = 0;
|
||||
return httpcode;
|
||||
}
|
||||
|
||||
int
|
||||
nc_fetchurl_file(CURL* curl, char* url, FILE* stream,
|
||||
unsigned long* sizep, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct Fetchdata fetchdata;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* send all data to this function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteFileCallback);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* we pass our file to the callback function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&fetchdata);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* One last thing; always try to get the last modified time */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
fetchdata.stream = stream;
|
||||
fetchdata.size = 0;
|
||||
cstat = curl_easy_perform(curl);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
if (stat == NC_NOERR) {
|
||||
/* return the file size*/
|
||||
if (sizep != NULL)
|
||||
*sizep = fetchdata.size;
|
||||
/* Get the last modified time */
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
}
|
||||
return THROW(stat);
|
||||
|
||||
fail:
|
||||
LOG((LOGERR, "curl error: %s", curl_easy_strerror(cstat)));
|
||||
return THROW(NC_ECURL);
|
||||
}
|
||||
|
||||
int
|
||||
nc_fetchurl(CURL* curl, char* url, NCbytes* buf, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* send all data to this function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* we pass our file to the callback function */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buf);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* One last thing; always try to get the last modified time */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat == CURLE_PARTIAL_FILE) {
|
||||
/* Log it but otherwise ignore */
|
||||
LOG((LOGWARN, "curl error: %s; ignored",
|
||||
curl_easy_strerror(cstat)));
|
||||
cstat = CURLE_OK;
|
||||
}
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* Get the last modified time */
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* Null terminate the buffer*/
|
||||
ncbytesnull(buf);
|
||||
|
||||
return THROW(stat);
|
||||
|
||||
fail:
|
||||
LOG((LOGERR, "curl error: %s", curl_easy_strerror(cstat)));
|
||||
return THROW(NC_ECURL);
|
||||
}
|
||||
|
||||
static size_t
|
||||
WriteFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
|
||||
{
|
||||
size_t count;
|
||||
struct Fetchdata* fetchdata;
|
||||
fetchdata = (struct Fetchdata*) data;
|
||||
count = fwrite(ptr, size, nmemb, fetchdata->stream);
|
||||
if (count > 0) {
|
||||
fetchdata->size += (count * size);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"callback: %lu bytes",(unsigned long)(size*nmemb))));
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
static size_t
|
||||
WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
|
||||
{
|
||||
size_t realsize = size * nmemb;
|
||||
NCbytes* buf = (NCbytes*) data;
|
||||
if(realsize == 0)
|
||||
LOG((LOGWARN,"WriteMemoryCallback: zero sized chunk"));
|
||||
/* Optimize for reading potentially large dods datasets */
|
||||
if(!ncbytesavail(buf,realsize)) {
|
||||
/* double the size of the packet */
|
||||
ncbytessetalloc(buf,2*ncbytesalloc(buf));
|
||||
}
|
||||
ncbytesappendn(buf, ptr, realsize);
|
||||
return realsize;
|
||||
}
|
||||
|
||||
int
|
||||
nc_curlopen(CURL** curlp)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat;
|
||||
CURL* curl;
|
||||
/* initialize curl*/
|
||||
curl = curl_easy_init();
|
||||
if (curl == NULL) stat = NC_ECURL;
|
||||
else {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
if (cstat != CURLE_OK) stat = NC_ECURL;
|
||||
/* some servers don't like requests that are made without a user-agent */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
|
||||
if (cstat != CURLE_OK) stat = NC_ECURL;
|
||||
}
|
||||
if (curlp) *curlp = curl;
|
||||
return THROW(stat);
|
||||
}
|
||||
|
||||
void
|
||||
nc_curlclose(CURL* curl)
|
||||
{
|
||||
if (curl != NULL)
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
int
|
||||
nc_fetchlastmodified(CURL* curl, char* url, long* filetime)
|
||||
{
|
||||
int stat = NC_NOERR;
|
||||
CURLcode cstat = CURLE_OK;
|
||||
|
||||
/* Set the URL */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_URL, (void*)url);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
|
||||
/* Ask for head */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); /* 30sec timeout*/
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HEADER, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FILETIME, (long)1);
|
||||
|
||||
cstat = curl_easy_perform(curl);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
if(filetime != NULL)
|
||||
cstat = curl_easy_getinfo(curl,CURLINFO_FILETIME,filetime);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
|
||||
return THROW(stat);
|
||||
|
||||
fail:
|
||||
LOG((LOGERR, "curl error: %s", curl_easy_strerror(cstat)));
|
||||
return THROW(NC_ECURL);
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
|
||||
/* Set various general curl flags */
|
||||
int
|
||||
nc_set_curl_flags(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
#ifdef CURLOPT_ENCODING
|
||||
if (state->compress) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_ENCODING, 'deflate, gzip');
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_ENCODING=deflat, gzip"));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (state->cookiejar || state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIESESSION=1"));
|
||||
#endif
|
||||
}
|
||||
if (state->cookiejar) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEJAR, state->cookiejar);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOP_COOKIEJAR=%s",state->cookiejar);
|
||||
#endif
|
||||
}
|
||||
if (state->cookiefile) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_COOKIEFILE, state->cookiefile);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_COOKIEFILE=%s",state->cookiefile);
|
||||
#endif
|
||||
}
|
||||
if (state->verbose) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_VERBOSE=%ld",1L);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Following are always set */
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_FOLLOWLOCATION=%ld",1L);
|
||||
#endif
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
int
|
||||
nc_set_proxy(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXY, state->host);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXY=%s",state->host);
|
||||
#endif
|
||||
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYPORT, state->port);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYPORT=%d",state->port);
|
||||
#endif
|
||||
|
||||
if (state->username) {
|
||||
char *combined = combinecredentials(state->username,state->password);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, combined);
|
||||
free(combined);
|
||||
if (cstat != CURLE_OK) return NC_ECURL;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYUSERPWD=%s",combined);
|
||||
#endif
|
||||
#ifdef CURLOPT_PROXYAUTH
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_PROXYAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
nc_set_ssl(CURL* curl, NCCDMR* nccr)
|
||||
{
|
||||
CURLcode cstat = CURLE_OK;
|
||||
struct NCCURLSTATE* state = &nccr->curl;
|
||||
long verify = (state->validate?1L:0L);
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, verify);
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYPEER=%ld",verify);
|
||||
#endif
|
||||
cstat=curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, (verify?2L:0L));
|
||||
if (cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSL_VERIFYHOST=%ld",(verify?2L:0L));
|
||||
#endif
|
||||
{
|
||||
if(state->certificate) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLCERT, state->certificate);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLCERT=%s",state->certificate);
|
||||
#endif
|
||||
}
|
||||
if(state->key) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_SSLKEY, state->key);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->keypasswd) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_KEYPASSWD, state->keypasswd);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_SSLKEY=%s",state->key);
|
||||
#endif
|
||||
}
|
||||
if(state->cainfo) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAINFO, state->cainfo);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAINFO=%s",state->cainfo);
|
||||
#endif
|
||||
}
|
||||
if(state->capath) {
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_CAPATH, state->capath);
|
||||
if(cstat != CURLE_OK) goto fail;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_CAPATH=%s",state->capath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return NC_NOERR;
|
||||
|
||||
fail:
|
||||
return NC_ECURL;
|
||||
}
|
||||
|
||||
/* This is called with arguments while the other functions in this file are
|
||||
* used with global values read from the.dodsrc file. The reason is that
|
||||
* we may have multiple password sources.
|
||||
*/
|
||||
int
|
||||
nc_set_user_password(CURL* curl, const char *userC, const char *passwordC)
|
||||
{
|
||||
CURLcode cstat;
|
||||
char* combined = NULL;
|
||||
|
||||
if(userC == NULL && passwordC == NULL) return NC_NOERR;
|
||||
if(userC == NULL) userC = "";
|
||||
if(passwordC == NULL) passwordC = "";
|
||||
|
||||
combined = combinecredentials(userC,passwordC);
|
||||
if (!combined) return NC_ENOMEM;
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_USERPWD, combined);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_USERPWD=%s",combined);
|
||||
#endif
|
||||
cstat = curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
||||
if (cstat != CURLE_OK) goto done;
|
||||
#ifdef DEBUG
|
||||
LOG((LOGNOTE,"CURLOPT_HTTPAUTH=%ld",(long)CURLAUTH_ANY);
|
||||
#endif
|
||||
|
||||
done:
|
||||
if(combined != NULL) free(combined);
|
||||
return (cstat == CURLE_OK?NC_NOERR:NC_ECURL);
|
||||
}
|
||||
|
||||
|
||||
static char*
|
||||
combinecredentials(const char* user, const char* pwd)
|
||||
{
|
||||
int userPassSize = strlen(user) + strlen(pwd) + 2;
|
||||
char *userPassword = malloc(sizeof(char) * userPassSize);
|
||||
if (!userPassword) {
|
||||
LOG((LOGERR,"Out of Memory\n"));
|
||||
return NULL;
|
||||
}
|
||||
strcpy(userPassword, user);
|
||||
strcat(userPassword, ":");
|
||||
strcat(userPassword, pwd);
|
||||
return userPassword;
|
||||
}
|
53
libcdmr/curlwrap.h
Normal file
53
libcdmr/curlwrap.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id$" */
|
||||
|
||||
#ifndef CURLWRAP_H
|
||||
#define CURLWRAP_H
|
||||
|
||||
extern int nc_curlopen(CURL**);
|
||||
extern void nc_curlclose(CURL*);
|
||||
|
||||
extern int nc_set_curl_flags(CURL*, NCCDMR*);
|
||||
extern int nc_set_proxy(CURL*, NCCDMR*);
|
||||
extern int nc_set_ssl(CURL*, NCCDMR*);
|
||||
extern int nc_set_user_password(CURL*, const char *userC, const char *passwordC);
|
||||
|
||||
#ifdef IGNORE
|
||||
extern long nc_fetchhttpcode(CURL*);
|
||||
extern int nc_fetchurl_file(CURL*, char* url, FILE* stream, unsigned long* sizep, long* filetime);
|
||||
extern int nc_fetchurl(CURL*, char* url, NCbytes* buf, long* filetime);
|
||||
extern int nc_fetchlastmodified(CURL*, char* url, long* filetime);
|
||||
#endif
|
||||
|
||||
#endif /*CURLWRAP_H*/
|
190
libcdmr/nccr.c
Normal file
190
libcdmr/nccr.c
Normal file
@ -0,0 +1,190 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#include "nccr.h"
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "nccr.h"
|
||||
#include "nccrdispatch.h"
|
||||
#include "nc4dispatch.h"
|
||||
#include "crdebug.h"
|
||||
#include "curlwrap.h"
|
||||
|
||||
/* Mnemonic */
|
||||
#define getncid(drno) (((NC*)drno)->ext_ncid)
|
||||
|
||||
extern NC_FILE_INFO_T* nc_file;
|
||||
|
||||
static void nccrdinitialize(void);
|
||||
|
||||
static int nccrdinitialized = 0;
|
||||
|
||||
static void freeNCCDMR(NCCDMR* cdmr);
|
||||
|
||||
/**************************************************/
|
||||
int
|
||||
NCCR_new_nc(NC** ncpp)
|
||||
{
|
||||
NCCR* ncp;
|
||||
/* Allocate memory for this info. */
|
||||
if (!(ncp = calloc(1, sizeof(struct NCCR))))
|
||||
return NC_ENOMEM;
|
||||
if(ncpp) *ncpp = (NC*)ncp;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* See ncd4dispatch.c for other version */
|
||||
int
|
||||
NCCR_open(const char * path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
int useparallel, void* mpidata,
|
||||
NC_Dispatch* dispatch, NC** ncpp)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
NC_URL* tmpurl;
|
||||
NCCR* nccr = NULL; /* reuse the ncdap3 structure*/
|
||||
NC_HDF5_FILE_INFO_T* h5 = NULL;
|
||||
NC_GRP_INFO_T *grp = NULL;
|
||||
int ncid = -1;
|
||||
int fd;
|
||||
char* tmpname = NULL;
|
||||
NClist* shows;
|
||||
|
||||
LOG((1, "nc_open_file: path %s mode %d", path, mode));
|
||||
|
||||
if(!nccrdinitialized) nccrdinitialize();
|
||||
|
||||
if(!nc_urlparse(path,&tmpurl)) PANIC("libcdmr: non-url path");
|
||||
nc_urlfree(tmpurl); /* no longer needed */
|
||||
|
||||
/* Check for legal mode flags */
|
||||
if((mode & NC_WRITE) != 0) ncstat = NC_EINVAL;
|
||||
else if(mode & (NC_WRITE|NC_CLOBBER)) ncstat = NC_EPERM;
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
|
||||
mode = (mode & ~(NC_MPIIO | NC_MPIPOSIX));
|
||||
/* Despite the above check, we want the file to be initially writable */
|
||||
mode |= (NC_WRITE|NC_CLOBBER);
|
||||
|
||||
/* Use NCCR code to establish a pseudo file */
|
||||
tmpname = nulldup(PSEUDOFILE);
|
||||
fd = mkstemp(tmpname);
|
||||
if(fd < 0) {THROWCHK(errno); goto done;}
|
||||
/* Now, use the file to create the hdf5 file */
|
||||
ncstat = NC4_create(tmpname,NC_NETCDF4|NC_CLOBBER,
|
||||
0,0,NULL,0,NULL,dispatch,(NC**)&nccr);
|
||||
ncid = nccr->info.ext_ncid;
|
||||
/* unlink the temp file so it will automatically be reclaimed */
|
||||
unlink(tmpname);
|
||||
free(tmpname);
|
||||
/* Avoid fill */
|
||||
dispatch->set_fill(ncid,NC_NOFILL,NULL);
|
||||
if(ncstat)
|
||||
{THROWCHK(ncstat); goto done;}
|
||||
/* Find our metadata for this file. */
|
||||
ncstat = nc4_find_nc_grp_h5(ncid, (NC_FILE_INFO_T**)&nccr, &grp, &h5);
|
||||
if(ncstat)
|
||||
{THROWCHK(ncstat); goto done;}
|
||||
|
||||
/* Setup tentative NCCR state*/
|
||||
nccr->cdmr->controller = (NC*)nccr;
|
||||
nccr->cdmr->urltext = nulldup(path);
|
||||
nc_urlparse(nccr->cdmr->urltext,&nccr->cdmr->url);
|
||||
nccr->info.dispatch = dispatch;
|
||||
|
||||
/* Create the curl connection (does not make the server connection)*/
|
||||
ncstat = nc_curlopen(&nccr->cdmr->curl.curl);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
|
||||
shows = nc_urllookup(nccr->cdmr->url,"show");
|
||||
if(nc_urllookupvalue(shows,"fetch"))
|
||||
nccr->cdmr->controls |= SHOWFETCH;
|
||||
|
||||
/* fetch and build the meta data */
|
||||
ncstat = crbuildnc(nccr);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
|
||||
/* Mark as no longer indef and no longer writable*/
|
||||
h5->flags &= ~(NC_INDEF);
|
||||
h5->no_write = 1;
|
||||
|
||||
done:
|
||||
if(ncstat) {
|
||||
if(nccr != NULL) {
|
||||
int ncid = nccr->info.ext_ncid;
|
||||
freeNCCDMR(nccr->cdmr);
|
||||
NCCR_abort(ncid);
|
||||
}
|
||||
} else {
|
||||
if(ncpp) *ncpp = (NC*)nccr;
|
||||
}
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
int
|
||||
NCCR_close(int ncid)
|
||||
{
|
||||
NC_GRP_INFO_T *grp;
|
||||
NC_HDF5_FILE_INFO_T *h5;
|
||||
NCCR* nccr = NULL;
|
||||
int ncstat = NC_NOERR;
|
||||
|
||||
LOG((1, "nc_close: ncid 0x%x", ncid));
|
||||
/* Find our metadata for this file. */
|
||||
ncstat = nc4_find_nc_grp_h5(ncid, (NC_FILE_INFO_T**)&nccr, &grp, &h5);
|
||||
if(ncstat != NC_NOERR) return THROW(ncstat);
|
||||
|
||||
/* This must be the root group. */
|
||||
if (grp->parent) ncstat = NC_EBADGRPID;
|
||||
|
||||
/* Destroy/close the NCCR state */
|
||||
freeNCCDMR(nccr->cdmr);
|
||||
|
||||
/* Destroy/close the NC_FILE_INFO_T state */
|
||||
NCCR_abort(ncid);
|
||||
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
/* Auxilliary routines */
|
||||
/**************************************************/
|
||||
|
||||
static void
|
||||
nccrdinitialize()
|
||||
{
|
||||
nccrdinitialized = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
freeNCCDMR(NCCDMR* cdmr)
|
||||
{
|
||||
if(cdmr == NULL) return;
|
||||
if(cdmr->urltext) free(cdmr->urltext);
|
||||
nc_urlfree(cdmr->url);
|
||||
if(cdmr->curl.curl) nc_curlclose(cdmr->curl.curl);
|
||||
if(cdmr->curl.host) free(cdmr->curl.host);
|
||||
if(cdmr->curl.useragent) free(cdmr->curl.useragent);
|
||||
if(cdmr->curl.cookiefile) free(cdmr->curl.cookiefile);
|
||||
if(cdmr->curl.certificate) free(cdmr->curl.certificate);
|
||||
if(cdmr->curl.key) free(cdmr->curl.key);
|
||||
if(cdmr->curl.keypasswd) free(cdmr->curl.keypasswd);
|
||||
if(cdmr->curl.cainfo) free(cdmr->curl.cainfo);
|
||||
if(cdmr->curl.capath) free(cdmr->curl.capath);
|
||||
if(cdmr->curl.username) free(cdmr->curl.username);
|
||||
if(cdmr->curl.password) free(cdmr->curl.password);
|
||||
free(cdmr);
|
||||
}
|
||||
|
102
libcdmr/nccr.h
Normal file
102
libcdmr/nccr.h
Normal file
@ -0,0 +1,102 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef NCCR_H
|
||||
#define NCCR_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "ncbytes.h"
|
||||
#include "nclist.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "ncdispatch.h"
|
||||
#include "nc4internal.h"
|
||||
#include "nc.h"
|
||||
|
||||
#include "crdebug.h"
|
||||
#include "crutil.h"
|
||||
|
||||
/**************************************************/
|
||||
/* The NCCR structure is subtype of NC_INFO_TYPE_T (libsrc4) */
|
||||
|
||||
typedef struct NCCDMR {
|
||||
NC* controller; /* Parent instance of NCDAP3 or NCDAP4 */
|
||||
char* urltext; /* as given to open()*/
|
||||
NC_URL* url;
|
||||
/* Track some flags */
|
||||
int controls;
|
||||
/* Store curl state info */
|
||||
struct NCCURLSTATE {
|
||||
CURL* curl;
|
||||
int curlflags;
|
||||
int compress;
|
||||
int verbose;
|
||||
int followlocation;
|
||||
int maxredirs;
|
||||
char *host;
|
||||
int port;
|
||||
char *username;
|
||||
char *password;
|
||||
char* useragent;
|
||||
char* cookiejar;
|
||||
char* cookiefile;
|
||||
int validate;
|
||||
char* certificate;
|
||||
char* key;
|
||||
char* keypasswd;
|
||||
char* cainfo; /* certificate authority */
|
||||
char* capath;
|
||||
} curl;
|
||||
} NCCDMR;
|
||||
|
||||
typedef struct NCCURLSTATE NCCURLSTATE;
|
||||
|
||||
typedef struct NCCR {
|
||||
NC_FILE_INFO_T info;
|
||||
NCCDMR* cdmr;
|
||||
} NCCR;
|
||||
|
||||
/**************************************************/
|
||||
/* Define various flags (powers of 2)*/
|
||||
#define SHOWFETCH (0x1)
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* Give PSEUDOFILE a value */
|
||||
#define PSEUDOFILE "/tmp/pseudofileXXXXXX"
|
||||
|
||||
/* Replacement for strdup (in libsrc) */
|
||||
#ifdef HAVE_STRDUP
|
||||
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
|
||||
#else
|
||||
extern char* nulldup(const char*);
|
||||
#endif
|
||||
|
||||
#define nulllen(s) (s==NULL?0:strlen(s))
|
||||
#define nullstring(s) (s==NULL?"(null)":s)
|
||||
|
||||
/**************************************************/
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
extern int nccrceparse(char*, int, NClist**, NClist**, char**);
|
||||
|
||||
extern NCerror crbuildnc(NCCR*);
|
||||
|
||||
/**********************************************************/
|
||||
|
||||
#endif /*NCCR_H*/
|
173
libcdmr/nccrconstraints.c
Executable file
173
libcdmr/nccrconstraints.c
Executable file
@ -0,0 +1,173 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap4/constraints4.c,v 1.9 2010/04/13 03:36:31 dmh Exp $
|
||||
*********************************************************************/
|
||||
#include "ncdap4.h"
|
||||
#include "dapodom.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "dapdump.h"
|
||||
#endif
|
||||
|
||||
/* In order to construct the projection,
|
||||
we need to make sure to match the relevant dimensions
|
||||
against the relevant nodes in which the ultimate target
|
||||
is contained.
|
||||
*/
|
||||
NCerror
|
||||
buildvaraprojection4(Getvara* getvar,
|
||||
const size_t* startp, const size_t* countp, const ptrdiff_t* stridep,
|
||||
NCprojection** projectionp)
|
||||
{
|
||||
int i;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
NClist* dimset;
|
||||
CDFnode* var = getvar->target;
|
||||
NCprojection* projection = NULL;
|
||||
NClist* segments = NULL;
|
||||
NCsegment* segment;
|
||||
|
||||
segment = createncsegment();
|
||||
segment->node = var;
|
||||
ASSERT((segment->node != NULL));
|
||||
segment->name = nulldup(segment->node->name);
|
||||
segment->slicesdefined = 0; /* temporary */
|
||||
segments = nclistnew();
|
||||
nclistpush(segments,(ncelem)segment);
|
||||
|
||||
projection = createncprojection();
|
||||
projection->discrim = NS_VAR;
|
||||
projection->var = createncvar();
|
||||
projection->var->leaf = var;
|
||||
projection->var->segments = segments;
|
||||
|
||||
/* All slices are assigned to the first (and only segment) */
|
||||
dimset = var->array.dimensions;
|
||||
segment->slicerank = nclistlength(var->array.dimensions);
|
||||
for(i=0;i<segment->slicerank;i++) {
|
||||
NCslice* slice = &segment->slices[i];
|
||||
CDFnode* dim = (CDFnode*)nclistget(dimset,i);
|
||||
slice->first = startp[i];
|
||||
slice->stride = stridep[i];
|
||||
slice->count = countp[i];
|
||||
slice->length = slice->count * slice->stride;
|
||||
slice->stop = (slice->first + slice->length);
|
||||
ASSERT(dim->dim.declsize > 0);
|
||||
slice->declsize = dim->dim.declsize;
|
||||
}
|
||||
segment->slicesdefined = 1;
|
||||
|
||||
if(projectionp) *projectionp = projection;
|
||||
if(ncstat) freencprojection(projection);
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
/* Compute the set of prefetched data */
|
||||
NCerror
|
||||
prefetchdata4(NCCR* drno)
|
||||
{
|
||||
int i,j;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
NClist* allvars = drno->dap.cdf.varnodes;
|
||||
NCconstraint* constraint = drno->dap.oc.dapconstraint;
|
||||
NClist* vars = nclistnew();
|
||||
NCcachenode* cache = NULL;
|
||||
NCconstraint* newconstraint;
|
||||
|
||||
/* If caching is off, and we can do constraints, then
|
||||
don't even do prefetch
|
||||
*/
|
||||
if(!FLAGSET(drno->dap.controls,NCF_CACHE) && !FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)) {
|
||||
drno->dap.cdf.cache->prefetch = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
for(i=0;i<nclistlength(allvars);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(allvars,i);
|
||||
size_t nelems = 1;
|
||||
/* Compute the # of elements in the variable */
|
||||
for(j=0;j<nclistlength(var->array.dimensions);j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(var->array.dimensions,j);
|
||||
nelems *= dim->dim.declsize;
|
||||
}
|
||||
/* If we cannot constrain, then pull in everything */
|
||||
if(FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)
|
||||
|| nelems <= drno->dap.cdf.smallsizelimit)
|
||||
nclistpush(vars,(ncelem)var);
|
||||
}
|
||||
|
||||
/* If we cannot constrain, then pull in everything */
|
||||
newconstraint = createncconstraint();
|
||||
if(FLAGSET(drno->dap.controls,NCF_UNCONSTRAINABLE)) {
|
||||
newconstraint->projections = NULL;
|
||||
newconstraint->selections= NULL;
|
||||
} else { /* Construct the projections for this set of vars */
|
||||
/* Construct the projections for this set of vars */
|
||||
/* Initially, the constraints are same as the merged constraints */
|
||||
newconstraint->projections = clonencprojections(constraint->projections);
|
||||
restrictprojection34(vars,newconstraint->projections);
|
||||
/* similar for selections */
|
||||
newconstraint->selections = clonencselections(constraint->selections);
|
||||
}
|
||||
|
||||
ncstat = buildcachenode34(&drno->dap,newconstraint,vars,&cache,0);
|
||||
if(ncstat) goto done;
|
||||
|
||||
if(FLAGSET(drno->dap.controls,NCF_SHOWFETCH)) {
|
||||
/* Log the set of prefetch variables */
|
||||
NCbytes* buf = ncbytesnew();
|
||||
ncbytescat(buf,"prefetch.vars: ");
|
||||
for(i=0;i<nclistlength(vars);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(vars,i);
|
||||
ncbytescat(buf," ");
|
||||
ncbytescat(buf,makesimplepathstring3(var));
|
||||
}
|
||||
ncbytescat(buf,"\n");
|
||||
oc_log(OCLOGNOTE,ncbytescontents(buf));
|
||||
ncbytesfree(buf);
|
||||
}
|
||||
|
||||
done:
|
||||
if(ncstat) {
|
||||
freenccachenode(&drno->dap,cache);
|
||||
}
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Based on the tactic, determine the set of variables to add */
|
||||
static void
|
||||
computevarset4(NCCR* drno, Getvara* getvar, NClist* varlist)
|
||||
{
|
||||
int i;
|
||||
nclistclear(varlist);
|
||||
for(i=0;i<nclistlength(drno->dap.cdf.varnodes);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(drno->dap.cdf.varnodes,i);
|
||||
#ifdef IGNORE
|
||||
int ok = 1;
|
||||
for(j=0;j<nclistlength(var->array.ncdimensions);j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(var->array.ncdimensions,j);
|
||||
if(dim->dim.declsize == NC_UNLIMITED) {ok = 0; break;}
|
||||
}
|
||||
if(!ok) continue;
|
||||
#endif
|
||||
switch (getvar->tactic->tactic) {
|
||||
case tactic_all: /* add all visible variables */
|
||||
nclistpush(varlist,(ncelem)var);
|
||||
break;
|
||||
case tactic_partial: /* add only small variables + target */
|
||||
if(var->estimatedsize < drno->dap.cdf.smallsizelimit
|
||||
|| getvar->target == var) {
|
||||
nclistpush(varlist,(ncelem)var);
|
||||
}
|
||||
break;
|
||||
case tactic_var: /* add only target var */
|
||||
if(getvar->target == var) nclistpush(varlist,(ncelem)var);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
115
libcdmr/nccrconstraints.h
Normal file
115
libcdmr/nccrconstraints.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap4/constraints4.h,v 1.1 2009/10/01 18:50:17 dmh Exp $
|
||||
*********************************************************************/
|
||||
#ifndef NCCRCONSTRAINTS_H
|
||||
#define NCCRCONSTRAINTS_H 1
|
||||
|
||||
typedef enum NCsort {
|
||||
NS_NIL=0,
|
||||
NS_EQ=1,NS_NEQ=2,NS_GE=3,NS_GT=4,NS_LT=5,NS_LE=6,NS_RE=7,
|
||||
NS_STR=8,NS_INT=9,NS_FLOAT=10,
|
||||
NS_VAR=11,NS_FCN=12,NS_CONST=13,
|
||||
NS_SELECT=14, NS_PROJECT=15,
|
||||
NS_SEGMENT=16, NS_SLICE=17,
|
||||
NS_CONSTRAINT=18,
|
||||
NS_VALUE=19
|
||||
} NCsort;
|
||||
|
||||
/* Must match NCsort */
|
||||
#define OPSTRINGS \
|
||||
{"?","=","!=",">=",">","<=","<","=~","?","?","?","?","?","?","?","?","?","?","?"}
|
||||
|
||||
|
||||
/* Provide a universal cast type */
|
||||
typedef struct NCany {
|
||||
NCsort sort;
|
||||
} NCany;
|
||||
|
||||
/*
|
||||
Store the relevant parameters for accessing
|
||||
data for a particular variable
|
||||
Break up the startp, countp, stridep into slices
|
||||
to facilitate the odometer walk
|
||||
*/
|
||||
|
||||
typedef struct NCslice {
|
||||
NCsort sort;
|
||||
size_t first;
|
||||
size_t count;
|
||||
size_t length; /* count*stride */
|
||||
size_t stride;
|
||||
size_t stop; /* == first + count*/
|
||||
size_t declsize; /* from defining dimension, if any.*/
|
||||
} NCslice;
|
||||
|
||||
|
||||
typedef struct NCsegment {
|
||||
NCsort sort;
|
||||
char* name;
|
||||
struct CDFnode* node;
|
||||
int slicesdefined; /* do we know yet if this has defined slices */
|
||||
unsigned int slicerank; /* Note: this is the rank as shown in the
|
||||
projection; may be less than node->array.rank */
|
||||
NCslice slices[NC_MAX_VAR_DIMS];
|
||||
} NCsegment;
|
||||
|
||||
typedef struct NCfcn {
|
||||
NCsort sort;
|
||||
char* name;
|
||||
NClist* args;
|
||||
} NCfcn;
|
||||
|
||||
typedef struct NCvar {
|
||||
NCsort sort;
|
||||
NClist* segments;
|
||||
struct CDFnode* node;
|
||||
/* Following duplicate info inferrable from the segments */
|
||||
struct CDFnode* leaf;
|
||||
} NCvar;
|
||||
|
||||
typedef struct NCconstant {
|
||||
NCsort sort;
|
||||
NCsort discrim;
|
||||
char* text;
|
||||
long long intvalue;
|
||||
double floatvalue;
|
||||
} NCconstant;
|
||||
|
||||
typedef struct NCvalue {
|
||||
NCsort sort;
|
||||
NCsort discrim;
|
||||
NCconstant* constant;
|
||||
NCvar* var;
|
||||
NCfcn* fcn;
|
||||
} NCvalue;
|
||||
|
||||
typedef struct NCselection {
|
||||
NCsort sort;
|
||||
NCsort operator;
|
||||
NCvalue* lhs;
|
||||
NClist* rhs;
|
||||
} NCselection;
|
||||
|
||||
typedef struct NCprojection {
|
||||
NCsort sort;
|
||||
NCsort discrim;
|
||||
NCvar* var;
|
||||
NCfcn* fcn;
|
||||
} NCprojection;
|
||||
|
||||
typedef struct NCconstraint {
|
||||
NCsort sort;
|
||||
NClist* projections;
|
||||
NClist* selections;
|
||||
} NCconstraint;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*NCCRCONSTRAINTS_H*/
|
||||
|
||||
|
35
libcdmr/nccrcvt
Normal file
35
libcdmr/nccrcvt
Normal file
@ -0,0 +1,35 @@
|
||||
rm -f tmp1 tmp2
|
||||
cp translation.html tmp1
|
||||
sed -e 's|[&]gt;|>|g' -e 's|[&]lt;|<|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|‑|-|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<p>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<html>||g' -e 's|</html>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<body>||g' -e 's|</body>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<ol>|@enumerate|g' -e 's|</ol>|@end enumerate|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<ul>|@itemize|g' -e 's|</ul>|@end itemize|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<li>|@item |g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<pre>|@verbatim|g' -e 's|</pre>|@end verbatim|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<a[^>]*>||g' -e 's|</a>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h1>|@subsection |g' -e 's|</h1>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h2>|@subsubsection |g' -e 's|</h2>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<h3>|@subsubsection |g' -e 's|</h3>||g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<table[^>]*>|@table @emph|g' -e 's|</table>|@end table|g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
sed -e 's|<tr>|@item |g' -e 's|<td>| |g' -e 's|<th>| |g' <tmp1 >tmp2
|
||||
rm tmp1; mv tmp2 tmp1
|
||||
mv tmp1 ../man4/translation.texi
|
||||
rm -fr tmp1 tmp2
|
||||
scp translation.html conan:/content/staff/dmh/daptranslation.html
|
171
libcdmr/nccrdispatch.c
Executable file
171
libcdmr/nccrdispatch.c
Executable file
@ -0,0 +1,171 @@
|
||||
/*********************************************************************
|
||||
* Copyright 1993, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Header: /upc/share/CVS/netcdf-3/libncdap4/ncd4dispatch.c,v 1.8 2010/05/27 21:34:10 dmh Exp $
|
||||
*********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "ncdispatch.h"
|
||||
#include "nc.h"
|
||||
#include "nccr.h"
|
||||
#include "nccrdispatch.h"
|
||||
|
||||
static int
|
||||
NCCR_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
int use_parallel, void* mpidata,
|
||||
NC_Dispatch*,NC** ncp);
|
||||
|
||||
static int NCCR_redef(int ncid);
|
||||
static int NCCR__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align);
|
||||
static int NCCR_put_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *edges0,
|
||||
const void *value0,
|
||||
nc_type memtype);
|
||||
|
||||
NC_Dispatch NCCR_dispatch_base = {
|
||||
|
||||
NC_DISPATCH_NCR,
|
||||
|
||||
NCCR_new_nc,
|
||||
|
||||
NCCR_create,
|
||||
NCCR_open,
|
||||
|
||||
NCCR_redef,
|
||||
NCCR__enddef,
|
||||
NCCR_sync,
|
||||
NCCR_abort,
|
||||
NCCR_close,
|
||||
NULL, /*set_fill*/
|
||||
NULL, /*inq_base_pe*/
|
||||
NULL, /*set_base_pe*/
|
||||
NULL, /*inq_format*/
|
||||
|
||||
NULL, /*inq*/
|
||||
NULL, /*inq_type*/
|
||||
|
||||
NULL, /*def_dim*/
|
||||
NULL, /*inq_dimid*/
|
||||
NULL, /*inq_dim*/
|
||||
NULL, /*inq_unlimdim*/
|
||||
NULL, /*rename_dim*/
|
||||
|
||||
NULL, /*inq_att*/
|
||||
NULL, /*inq_attid*/
|
||||
NULL, /*inq_attname*/
|
||||
NULL, /*rename_att*/
|
||||
NULL, /*del_att*/
|
||||
NULL, /*get_att*/
|
||||
NULL, /*put_att*/
|
||||
|
||||
NULL, /*def_var*/
|
||||
NULL, /*inq_varid*/
|
||||
NULL, /*rename_var*/
|
||||
NCCR_get_vara,
|
||||
NCCR_put_vara,
|
||||
NULL, /*inq_var_all*/
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
NULL, /*show_metadata*/
|
||||
NULL, /*inq_unlimdims*/
|
||||
NULL, /*var_par_access*/
|
||||
NULL, /*inq_ncid*/
|
||||
NULL, /*inq_grps*/
|
||||
NULL, /*inq_grpname*/
|
||||
NULL, /*inq_grpname_full*/
|
||||
NULL, /*inq_grp_parent*/
|
||||
NULL, /*inq_grp_full_ncid*/
|
||||
NULL, /*inq_varids*/
|
||||
NULL, /*inq_dimids*/
|
||||
NULL, /*inq_typeids*/
|
||||
NULL, /*inq_type_equal*/
|
||||
NULL, /*def_grp*/
|
||||
NULL, /*inq_user_type*/
|
||||
NULL, /*inq_typeid*/
|
||||
|
||||
NULL, /*def_compound*/
|
||||
NULL, /*insert_compound*/
|
||||
NULL, /*insert_array_compound*/
|
||||
NULL, /*inq_compound_field*/
|
||||
NULL, /*inq_compound_fieldindex*/
|
||||
NULL, /*def_vlen*/
|
||||
NULL, /*put_vlen_element*/
|
||||
NULL, /*get_vlen_element*/
|
||||
NULL, /*def_enum*/
|
||||
NULL, /*insert_enum*/
|
||||
NULL, /*inq_enum_member*/
|
||||
NULL, /*inq_enum_ident*/
|
||||
NULL, /*def_opaque*/
|
||||
NULL, /*def_var_deflate*/
|
||||
NULL, /*def_var_fletcher32*/
|
||||
NULL, /*def_var_chunking*/
|
||||
NULL, /*def_var_fill*/
|
||||
NULL, /*def_var_endian*/
|
||||
NULL, /*set_var_chunk_cache*/
|
||||
NULL, /*get_var_chunk_cache*/
|
||||
|
||||
#endif /*USE_NETCDF4*/
|
||||
|
||||
};
|
||||
|
||||
NC_Dispatch NCCR_dispatcher;
|
||||
|
||||
int
|
||||
NCCR_initialize(void)
|
||||
{
|
||||
/* Create our dispatch table as the merge of NC4 table
|
||||
plus some overrides */
|
||||
NC_dispatch_overlay(&NCCR_dispatch_base, NC4_dispatch_table, &NCCR_dispatcher);
|
||||
NCCR_dispatch_table = &NCCR_dispatcher;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
static int
|
||||
NCCR_create(const char *path, int cmode,
|
||||
size_t initialsz, int basepe, size_t *chunksizehintp,
|
||||
int use_parallel, void* mpidata,
|
||||
NC_Dispatch* dispatch, NC** ncp)
|
||||
{
|
||||
return NC_EPERM;
|
||||
}
|
||||
|
||||
static int
|
||||
NCCR_put_vara(int ncid, int varid,
|
||||
const size_t *start, const size_t *edges0,
|
||||
const void *value0,
|
||||
nc_type memtype)
|
||||
{
|
||||
return NC_EPERM;
|
||||
}
|
||||
|
||||
static int
|
||||
NCCR_redef(int ncid)
|
||||
{
|
||||
return (NC_EPERM);
|
||||
}
|
||||
|
||||
static int
|
||||
NCCR__enddef(int ncid, size_t h_minfree, size_t v_align, size_t v_minfree, size_t r_align)
|
||||
{
|
||||
return (NC_EPERM);
|
||||
}
|
||||
|
||||
int
|
||||
NCCR_sync(int ncid)
|
||||
{
|
||||
LOG((1, "nc_sync: ncid 0x%x", ncid));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
int
|
||||
NCCR_abort(int ncid)
|
||||
{
|
||||
LOG((1, "nc_abort: ncid 0x%x", ncid));
|
||||
/* Turn into close */
|
||||
return NCCR_close(ncid);
|
||||
}
|
||||
|
97
libcdmr/nccrdispatch.h
Normal file
97
libcdmr/nccrdispatch.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata
|
||||
*
|
||||
* Portions of this software were developed by the Unidata Program at the
|
||||
* University Corporation for Atmospheric Research.
|
||||
*
|
||||
* Access and use of this software shall impose the following obligations
|
||||
* and understandings on the user. The user is granted the right, without
|
||||
* any fee or cost, to use, copy, modify, alter, enhance and distribute
|
||||
* this software, and any derivative works thereof, and its supporting
|
||||
* documentation for any purpose whatsoever, provided that this entire
|
||||
* notice appears in all copies of the software, derivative works and
|
||||
* supporting documentation. Further, UCAR requests that the user credit
|
||||
* UCAR/Unidata in any publications that result from the use of this
|
||||
* software or in any product that includes this software. The names UCAR
|
||||
* and/or Unidata, however, may not be used in any advertising or publicity
|
||||
* to endorse or promote any products or commercial entity unless specific
|
||||
* written permission is obtained from UCAR/Unidata. The user also
|
||||
* understands that UCAR/Unidata is not obligated to provide the user with
|
||||
* any support, consulting, training or assistance of any kind with regard
|
||||
* to the use, operation and performance of this software nor to provide
|
||||
* the user with any updates, revisions, new versions or "bug fixes."
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/* "$Id: NCCRdispatch.h,v 1.3 2010/05/27 21:34:11 dmh Exp $" */
|
||||
|
||||
#ifndef _NCCRDISPATCH_H
|
||||
#define _NCCRDISPATCH_H
|
||||
|
||||
#include <stddef.h> /* size_t, ptrdiff_t */
|
||||
#include "netcdf.h"
|
||||
#include "ncdispatch.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* The Interface
|
||||
*/
|
||||
|
||||
/* Declaration modifiers for DLL support (MSC et al) */
|
||||
|
||||
#if defined(DLL_NETCDF) /* define when library is a DLL */
|
||||
# if defined(DLL_EXPORT) /* define when building the library */
|
||||
# define MSC_EXTRA __declspec(dllexport)
|
||||
# else
|
||||
# define MSC_EXTRA __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
#define MSC_EXTRA
|
||||
#endif /* defined(DLL_NETCDF) */
|
||||
|
||||
# define EXTERNL extern MSC_EXTRA
|
||||
|
||||
/**/
|
||||
|
||||
EXTERNL int
|
||||
NCCR_new_nc(NC**);
|
||||
|
||||
/* WARNING: this signature differs from external nc_open API*/
|
||||
EXTERNL int
|
||||
NCCR_open(const char *path, int mode,
|
||||
int basepe, size_t *chunksizehintp,
|
||||
int use_parallel, void* mpidata,
|
||||
struct NC_Dispatch* dispatch, NC** ncp);
|
||||
|
||||
EXTERNL int
|
||||
NCCR_close(int ncid);
|
||||
|
||||
EXTERNL int
|
||||
NCCR_get_vara(int ncid, int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
void* data,
|
||||
nc_type externaltype0);
|
||||
|
||||
EXTERNL int NCCR_close(int ncid);
|
||||
EXTERNL int NCCR_sync(int ncid);
|
||||
EXTERNL int NCCR_abort(int ncid);
|
||||
|
||||
/* End _var */
|
||||
|
||||
EXTERNL int NCCR_initialize(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_NCCRDISPATCH_H*/
|
22
libcdmr/nccrgetvara.c
Executable file
22
libcdmr/nccrgetvara.c
Executable file
@ -0,0 +1,22 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "ncdispatch.h"
|
||||
#include "nc.h"
|
||||
#include "nccr.h"
|
||||
#include "nccrdispatch.h"
|
||||
|
||||
int
|
||||
NCCR_get_vara(int ncid, int varid,
|
||||
const size_t* startp,
|
||||
const size_t* countp,
|
||||
void* data,
|
||||
nc_type externaltype0)
|
||||
{
|
||||
return NC_NOERR;
|
||||
}
|
325
libcdmr/nccrmeta.c
Normal file
325
libcdmr/nccrmeta.c
Normal file
@ -0,0 +1,325 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
* $Id$
|
||||
* $Header$
|
||||
*********************************************************************/
|
||||
|
||||
#include "nccr.h"
|
||||
|
||||
#ifdef IGNORE
|
||||
static NCerror crbuilddims(NCCR*);
|
||||
static NCerror crbuildtypes(NCCR*);
|
||||
static NCerror crbuildtypesr(NCCR*);
|
||||
static NCerror crbuildvars(NCCR*);
|
||||
static NCerror crbuildglobalattrs(NCCR*);
|
||||
static NCerror crbuildattribute(NCCR*, int varid, int ncid);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Fetch the metadata and define in the temporary netcdf-4 file
|
||||
*/
|
||||
NCerror
|
||||
crbuildnc(NCCR* nccr)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
#ifdef IGNORE
|
||||
CDFnode* dds = nccr->cdmr->cdf.ddsroot;
|
||||
ncstat = crbuildglobalattrs(cdmr,getncid(cdmr),dds);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
ncstat = crbuilddims(cdmr);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
ncstat = crbuildtypes(cdmr);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
ncstat = crbuildvars(cdmr);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
done:
|
||||
#endif
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Define dim info for top-level dims */
|
||||
static crNCerror
|
||||
builddims(NCCR* nccr)
|
||||
{
|
||||
unsigned int i,j;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
int dimid;
|
||||
int ncid = getncid(cdmr);
|
||||
NClist* dimset = nclistnew();
|
||||
|
||||
/* collect all dimensions from variables,
|
||||
including duplicates; note we use array.dimensions
|
||||
not array.ncdimensions.
|
||||
*/
|
||||
for(i=0;i<nclistlength(nccr->cdmr->cdf.varnodes);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(nccr->cdmr->cdf.varnodes,i);
|
||||
if(!var->visible) continue;
|
||||
nclistextend(dimset,nclistlength(var->array.dimensions));
|
||||
for(j=0;j<nclistlength(var->array.dimensions);j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(var->array.dimensions,j);
|
||||
int k,inserted = 0;
|
||||
/* Sort by fullname just for the fun of it */
|
||||
for(k=0;k<nclistlength(dimset);k++) {
|
||||
CDFnode* kdim = (CDFnode*)nclistget(dimset,k);
|
||||
if(strcmp(kdim->ncfullname,dim->ncfullname) > 0) {
|
||||
nclistinsert(dimset,k,(ncelem)dim);
|
||||
inserted = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!inserted) nclistpush(dimset,(ncelem)dim);
|
||||
}
|
||||
}
|
||||
|
||||
/* Define those top-level dims */
|
||||
for(i=0;i<nclistlength(dimset);i++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(dimset,i);
|
||||
if(dim->dim.basedim != NULL) continue;
|
||||
ncstat = nc_def_dim(ncid,dim->ncfullname,dim->dim.declsize,&dimid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
dim->ncid = dimid;
|
||||
}
|
||||
|
||||
/* Make all duplicate dims have same dimid as basedim*/
|
||||
/* (see computecdfdimnames)*/
|
||||
for(i=0;i<nclistlength(dimset);i++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(dimset,i);
|
||||
if(dim->dim.basedim != NULL) {
|
||||
dim->ncid = dim->dim.basedim->ncid;
|
||||
}
|
||||
}
|
||||
/*ok:*/
|
||||
done:
|
||||
nclistfree(dimset);
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
static crNCerror
|
||||
buildtypes(NCCR* nccr)
|
||||
{
|
||||
unsigned int i;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
/* Define user types in postorder */
|
||||
for(i=0;i<nclistlength(nccr->cdmr->cdf.usertypes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(nccr->cdmr->cdf.usertypes,i);
|
||||
if(!node->visible) continue;
|
||||
ncstat = buildtypes4r(cdmr,node);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
}
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
static NCerror
|
||||
buildtypes4r(NCCR* nccr, CDFnode* tnode)
|
||||
{
|
||||
unsigned int i,j;
|
||||
int typeid;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
if(!tnode->visible) goto done;
|
||||
|
||||
switch (tnode->nctype) {
|
||||
case NC_Sequence:
|
||||
/* Look for sequences that have a single field whose
|
||||
type is primitive; for these, we will not generate
|
||||
the compound type.
|
||||
*/
|
||||
if(tnode->singleton) {
|
||||
/* ok, just generate the vlen type using the sequence's
|
||||
singleton field */
|
||||
/* Find the first primitive visible field */
|
||||
CDFnode* prim = getsingletonfield(tnode->subnodes);
|
||||
ASSERT((prim != NULL));
|
||||
ncstat = nc_def_vlen(getncid(cdmr),tnode->vlenname,
|
||||
prim->etype,&typeid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
tnode->basetypeid = prim->etype;
|
||||
tnode->typeid = typeid;
|
||||
break;
|
||||
}
|
||||
/* fall thru */
|
||||
case NC_Grid:
|
||||
case NC_Structure:
|
||||
ncstat = nc_def_compound(getncid(cdmr),tnode->typesize.instance.size,
|
||||
tnode->typename,&typeid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
tnode->typeid = typeid;
|
||||
for(i=0;i<nclistlength(tnode->subnodes);i++) {
|
||||
CDFnode* field = (CDFnode*)nclistget(tnode->subnodes,i);
|
||||
if(!field->visible) continue;
|
||||
if(nclistlength(field->array.dimensions) == 0) {
|
||||
ncstat = nc_insert_compound(getncid(cdmr),typeid,
|
||||
field->ncbasename,
|
||||
field->typesize.field.offset,
|
||||
field->typeid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
} else {
|
||||
int dimsizes[NC_MAX_VAR_DIMS];
|
||||
for(j=0;j<nclistlength(field->array.dimensions);j++) {
|
||||
CDFnode* dim=(CDFnode*)nclistget(field->array.dimensions,j);
|
||||
dimsizes[j] = dim->dim.declsize;
|
||||
}
|
||||
ncstat = nc_insert_array_compound(getncid(cdmr),typeid,
|
||||
field->ncbasename,
|
||||
field->typesize.field.offset,
|
||||
field->typeid,
|
||||
nclistlength(field->array.dimensions),
|
||||
dimsizes);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
}
|
||||
}
|
||||
/* If the node is a sequence, also define the corresponding vlen type*/
|
||||
if(tnode->nctype == NC_Sequence) {
|
||||
ncstat = nc_def_vlen(getncid(cdmr),tnode->vlenname,tnode->typeid,&typeid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
tnode->basetypeid = typeid;
|
||||
tnode->typeid = typeid;
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_Primitive:
|
||||
break;
|
||||
|
||||
default: PANIC1("unexpected nctype: %d",tnode->nctype);
|
||||
}
|
||||
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
/* Simultaneously build any associated attributes */
|
||||
static crNCerror
|
||||
buildvars(NCCR* nccr)
|
||||
{
|
||||
/* Variables (in this translation) are (mostly)
|
||||
the direct fields of the Dataset*/
|
||||
unsigned int i,j;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
int varid;
|
||||
int ncid = getncid(cdmr);
|
||||
|
||||
for(i=0;i<nclistlength(nccr->cdmr->cdf.varnodes);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(nccr->cdmr->cdf.varnodes,i);
|
||||
NClist* vardims = var->array.dimensions;
|
||||
int dimids[NC_MAX_VAR_DIMS];
|
||||
int ncrank,dimindex=0;
|
||||
|
||||
if(!var->visible) continue;
|
||||
|
||||
ncrank = nclistlength(vardims);
|
||||
if(ncrank > 0) {
|
||||
dimindex = 0;
|
||||
for(j=0;j<ncrank;j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(vardims,j);
|
||||
dimids[dimindex++] = dim->ncid;
|
||||
}
|
||||
}
|
||||
setvarbasetype(&nccr->dap,var);
|
||||
ASSERT((var->typeid > 0));
|
||||
ncstat = nc_def_var(getncid(cdmr),var->ncfullname,
|
||||
var->typeid,
|
||||
nclistlength(var->array.dimensions),
|
||||
(ncrank==0?NULL:dimids),
|
||||
&varid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
var->ncid = varid;
|
||||
if(var->attributes != NULL) {
|
||||
for(j=0;j<nclistlength(var->attributes);j++) {
|
||||
NCattribute* att = (NCattribute*)nclistget(var->attributes,j);
|
||||
ncstat = crbuildattribute(cdmr,att,varid,ncid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
}
|
||||
}
|
||||
/* Tag the variable with its DAP path cr*/
|
||||
if(paramcheck3(&nccr->dap,"show","projection"))
|
||||
crshowprojection(&nccr->dap,var);
|
||||
}
|
||||
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
static crNCerror
|
||||
buildglobalattrs(NCCR* nccr, int ncid, CDFnode* root)
|
||||
{
|
||||
int i;
|
||||
const char* txt;
|
||||
char *nltxt, *p;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
if(root->attributes != NULL) {
|
||||
for(i=0;i<nclistlength(root->attributes);i++) {
|
||||
NCattribute* att = (NCattribute*)nclistget(root->attributes,i);
|
||||
ncstat = crbuildattribute(cdmr,att,NC_GLOBAL,ncid);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
}
|
||||
}
|
||||
|
||||
/* Define some additional system global attributes depending
|
||||
on show= clientparams*/
|
||||
/* Ignore doneures*/
|
||||
|
||||
crif(paramcheck3(&nccr->dap,"show","translate")) {
|
||||
/* Add a global attribute to show the translation */
|
||||
ncstat = nc_put_att_text(ncid,NC_GLOBAL,"_translate",
|
||||
strlen("netcdf-4"),"netcdf-4");
|
||||
}
|
||||
|
||||
crif(paramcheck3(&nccr->dap,"show","url")) {
|
||||
if(nccr->cdmr->oc.urltext != NULL)
|
||||
ncstat = nc_put_att_text(ncid,NC_GLOBAL,"_url",
|
||||
strlen(nccr->cdmr->oc.urltext),nccr->cdmr->oc.urltext);
|
||||
}
|
||||
crif(paramcheck3(&nccr->dap,"show","dds")) {
|
||||
txt = NULL;
|
||||
if(nccr->cdmr->cdf.ddsroot != NULL)
|
||||
txt = oc_inq_text(nccr->cdmr->oc.conn,nccr->cdmr->cdf.ddsroot->dds);
|
||||
if(txt != NULL) {
|
||||
/* 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(ncid,NC_GLOBAL,"_DDS",strlen(nltxt),nltxt);
|
||||
efree(nltxt);
|
||||
}
|
||||
}
|
||||
crif(paramcheck3(&nccr->dap,"show","das")) {
|
||||
txt = NULL;
|
||||
if(nccr->cdmr->oc.ocdasroot != OCNULL)
|
||||
txt = oc_inq_text(nccr->cdmr->oc.conn,nccr->cdmr->oc.ocdasroot);
|
||||
if(txt != NULL) {
|
||||
nltxt = nulldup(txt);
|
||||
for(p=nltxt;*p;p++) {if(*p == '\n' || *p == '\r' || *p == '\t') {*p = ' ';}};
|
||||
ncstat = nc_put_att_text(ncid,NC_GLOBAL,"_DAS",strlen(nltxt),nltxt);
|
||||
efree(nltxt);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
static NCerror
|
||||
crbuildattribute(NCCR* nccr, NCattribute* att, int varid, int ncid)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
char* cname = cdflegalname3(att->name);
|
||||
unsigned int nvalues = nclistlength(att->values);
|
||||
unsigned int typesize = nctypesizeof(att->etype);
|
||||
void* mem = emalloc(typesize * nvalues);
|
||||
|
||||
ncstat = dapcvtattrval3(att->etype,mem,att->values);
|
||||
ncstat = nc_put_att(ncid,varid,cname,att->etype,nvalues,mem);
|
||||
if(att->etype == NC_STRING) {
|
||||
int i;
|
||||
for(i=0;i<nvalues;i++) efree(((char**)mem)[i]);
|
||||
}
|
||||
efree(mem);
|
||||
free(cname);
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#endif
|
23
libcdmr/nccrstub.c
Normal file
23
libcdmr/nccrstub.c
Normal file
@ -0,0 +1,23 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
*********************************************************************/
|
||||
|
||||
/* $Id: stubdap4.c,v 1.4 2010/05/24 19:48:15 dmh Exp $ */
|
||||
/* $Header: /upc/share/CVS/netcdf-3/libncdap4/stubdap4.c,v 1.4 2010/05/24 19:48:15 dmh Exp $ */
|
||||
|
||||
#include "config.h"
|
||||
#include "netcdf.h"
|
||||
|
||||
extern int NC3_initialize(void);
|
||||
extern int NC4_initialize(void);
|
||||
extern int NCCR_initialize(void);
|
||||
|
||||
int
|
||||
NC_initialize(void)
|
||||
{
|
||||
NC3_initialize();
|
||||
NC4_initialize();
|
||||
NCCR_initialize();
|
||||
return NC_NOERR;
|
||||
}
|
19
libcdmr/t_cdmr.c
Normal file
19
libcdmr/t_cdmr.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* This example program is part of Unidata's netCDF library for
|
||||
scientific data access.
|
||||
|
||||
How about a short, but meaningful, netCDF program?
|
||||
|
||||
Ed Hartnett, 6/19/4
|
||||
$Id: simple.c,v 1.1 2004/07/26 14:04:42 ed Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <netcdf.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,24 +19,23 @@ noinst_LTLIBRARIES = libdispatch.la
|
||||
libdispatch_la_SOURCES = ncdispatch.h parallel.c copy.c file.c dim.c \
|
||||
att.c error.c var.c dispatch.c
|
||||
|
||||
# Provide our own version of the oc/dapurl code so we can
|
||||
# handle new url-based protocols like cdmremote.
|
||||
libdispatch_la_SOURCES += nc_url.c nc_url.h
|
||||
|
||||
# These really contain common utility code used by more
|
||||
# than one later library.
|
||||
# TODO: move logging code here so it can be used anywhere.
|
||||
libdispatch_la_SOURCES += nclist.c nclist.h \
|
||||
ncbytes.c ncbytes.h
|
||||
|
||||
# Add functions only found in netCDF-4.
|
||||
if USE_NETCDF4
|
||||
libdispatch_la_SOURCES += nc4.c
|
||||
endif # USE_NETCDF4
|
||||
|
||||
# Add functions needed by opendap client.
|
||||
if USE_DAP
|
||||
libdispatch_la_SOURCES += dap.c
|
||||
AM_CPPFLAGS += -I${top_srcdir}/oc
|
||||
endif # USE_DAP
|
||||
|
||||
# Add V2 API convenience library if needed.
|
||||
if BUILD_V2
|
||||
noinst_LTLIBRARIES += libnetcdf2.la
|
||||
libnetcdf2_la_SOURCES = v2i.c
|
||||
endif # BUILD_V2
|
||||
|
||||
.PHONY: visualstudio
|
||||
visualstudio:
|
||||
sh ${abs_top_srcdir}/visualbuild add ${abs_srcdir} "${libdispatch_la_SOURCES}"
|
||||
|
||||
|
@ -554,7 +554,7 @@ int
|
||||
nc_copy_att(int ncid_in, int varid_in, const char *name,
|
||||
int ncid_out, int varid_out)
|
||||
{
|
||||
int format, target_natts, target_attid, attid;
|
||||
int format, target_natts, target_attid;
|
||||
char att_name[NC_MAX_NAME + 1];
|
||||
int a, retval;
|
||||
|
||||
@ -599,7 +599,7 @@ nc_copy_att(int ncid_in, int varid_in, const char *name,
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((retval = nc_inq_attname(ncid_out, varid_out, a, &att_name)))
|
||||
if ((retval = nc_inq_attname(ncid_out, varid_out, a, att_name)))
|
||||
return retval;
|
||||
if ((retval = NC_copy_att(ncid_out, varid_out, att_name,
|
||||
ncid_out, varid_out)))
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
Copyright 2010 University Corporation for Atmospheric
|
||||
Research/Unidata. See COPYRIGHT file for more info.
|
||||
|
||||
This file defines the opendap-related functions.
|
||||
|
||||
"$Id: nc4.c,v 1.1 2010/06/01 15:46:50 ed Exp $"
|
||||
*/
|
||||
|
||||
#include "ncdispatch.h"
|
||||
|
||||
/* allow access dapurlparse and params while minimizing exposing dapurl.h */
|
||||
int
|
||||
NCDAP_urlparse(const char* s, void** dapurlp)
|
||||
{
|
||||
DAPURL* dapurl = NULL;
|
||||
dapurl = calloc(1,sizeof(DAPURL));
|
||||
if(dapurl == 0) return NC_ENOMEM;
|
||||
if(!dapurlparse(s,dapurl)) {
|
||||
dapurlclear(dapurl);
|
||||
free(dapurl);
|
||||
return NC_EINVAL;
|
||||
}
|
||||
if(dapurlp) *dapurlp = dapurl;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
void
|
||||
NCDAP_urlfree(void* durl)
|
||||
{
|
||||
DAPURL* dapurl = (DAPURL*)durl;
|
||||
if(dapurl != NULL) {
|
||||
dapurlclear(dapurl);
|
||||
free(dapurl);
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
NCDAP_urllookup(void* durl, const char* param)
|
||||
{
|
||||
DAPURL* dapurl = (DAPURL*)durl;
|
||||
if(param == NULL || strlen(param) == 0 || dapurl == NULL) return NULL;
|
||||
return dapurllookup(dapurl,param);
|
||||
}
|
||||
|
||||
|
||||
/* int */
|
||||
/* NCDAP_urlparse(const char* s, void** dapurlp) */
|
||||
/* { */
|
||||
/* return NC_EINVAL; */
|
||||
/* } */
|
||||
|
||||
/* void */
|
||||
/* NCDAP_urlfree(void* durl) */
|
||||
/* { */
|
||||
/* return; */
|
||||
/* } */
|
||||
|
||||
/* const char* */
|
||||
/* NCDAP_urllookup(void* durl, const char* param) */
|
||||
/* { */
|
||||
/* return NULL; */
|
||||
/* } */
|
@ -1,6 +1,26 @@
|
||||
#include "ncdispatch.h"
|
||||
#include "nc_url.h"
|
||||
|
||||
#define INITCOORD1 if(coord_one[0] != 1) {int i; for(i=0;i<NC_MAX_VAR_DIMS;i++) coord_one[i] = 1;}
|
||||
|
||||
/* Define the known protocols and their manipulations */
|
||||
static struct NCPROTOCOLLIST {
|
||||
char* protocol;
|
||||
char* substitute;
|
||||
int modelflags;
|
||||
} ncprotolist[] = {
|
||||
{"http",NULL,0},
|
||||
{"https",NULL,0},
|
||||
{"file",NULL,NC_DISPATCH_NCD},
|
||||
{"dods","http",NC_DISPATCH_NCD},
|
||||
{"dodss","https",NC_DISPATCH_NCD},
|
||||
{"cdmr","http",NC_DISPATCH_NCR|NC_DISPATCH_NC4},
|
||||
{"cdmrs","https",NC_DISPATCH_NCR|NC_DISPATCH_NC4},
|
||||
{"cdmremote","http",NC_DISPATCH_NCR|NC_DISPATCH_NC4},
|
||||
{"cdmremotes","https",NC_DISPATCH_NCR|NC_DISPATCH_NC4},
|
||||
{NULL,NULL,0} /* Terminate search */
|
||||
};
|
||||
|
||||
/*
|
||||
static nc_type longtype = (sizeof(long) == sizeof(int)?NC_INT:NC_INT64);
|
||||
static nc_type ulongtype = (sizeof(unsigned long) == sizeof(unsigned int)?NC_UINT:NC_UINT64);
|
||||
@ -20,38 +40,63 @@ NC_Dispatch* NCD3_dispatch_table = NULL;
|
||||
NC_Dispatch* NCD4_dispatch_table = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(USE_CDMREMOTE) && defined(USE_NETCDF4)
|
||||
NC_Dispatch* NCCR_dispatch_table = NULL;
|
||||
#endif
|
||||
|
||||
/* return 1 if path looks like a url; 0 otherwise */
|
||||
int
|
||||
NC_testurl(const char* path)
|
||||
{
|
||||
#ifdef USE_DAP
|
||||
void* tmpurl = NULL;
|
||||
if(NCDAP_urlparse(path,&tmpurl) == NC_NOERR) {
|
||||
NCDAP_urlfree(tmpurl);
|
||||
NC_URL* tmpurl = NULL;
|
||||
if(nc_urlparse(path,&tmpurl) == NC_NOERR) {
|
||||
nc_urlfree(tmpurl);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Return the OR of some of the NC_DISPATCH flags
|
||||
Assumes that the path is known to be a url
|
||||
*/
|
||||
|
||||
int
|
||||
NC_urlmodel(const char* path)
|
||||
{
|
||||
int model = 0;
|
||||
#ifdef USE_DAP
|
||||
void* tmpurl = NULL;
|
||||
if(NCDAP_urlparse(path,&tmpurl) == NC_NOERR) {
|
||||
if(NCDAP_urllookup(tmpurl,"netcdf4")
|
||||
|| NCDAP_urllookup(tmpurl,"netcdf-4")) {
|
||||
model = 4;
|
||||
} else if(NCDAP_urllookup(tmpurl,"netcdf3")
|
||||
|| NCDAP_urllookup(tmpurl,"netcdf-3")) {
|
||||
model = 3;
|
||||
} else {
|
||||
model = 0;
|
||||
}
|
||||
NCDAP_urlfree(tmpurl);
|
||||
NC_URL* tmpurl = NULL;
|
||||
struct NCPROTOCOLLIST* protolist;
|
||||
|
||||
if(nc_urlparse(path,&tmpurl) != NC_NOERR) goto done;
|
||||
|
||||
/* Look at any prefixed parameters */
|
||||
if(nc_urllookup(tmpurl,"netcdf4")
|
||||
|| nc_urllookup(tmpurl,"netcdf-4")) {
|
||||
model = (NC_DISPATCH_NC4|NC_DISPATCH_NCD);
|
||||
} else if(nc_urllookup(tmpurl,"netcdf3")
|
||||
|| nc_urllookup(tmpurl,"netcdf-3")) {
|
||||
model = (NC_DISPATCH_NC3|NC_DISPATCH_NCD);
|
||||
} else if(nc_urllookup(tmpurl,"cdmremote")
|
||||
|| nc_urllookup(tmpurl,"cdmr")) {
|
||||
model = (NC_DISPATCH_NCR|NC_DISPATCH_NC4);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now look at the protocol */
|
||||
for(protolist=ncprotolist;protolist->protocol;protolist++) {
|
||||
if(strcmp(tmpurl->protocol,protolist->protocol) == 0) {
|
||||
model |= protolist->modelflags;
|
||||
if(protolist->substitute)
|
||||
nc_urlsetprotocol(tmpurl,protolist->substitute);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Force NC_DISPATCH_NC3 if necessary */
|
||||
if((model & NC_DISPATCH_NC4) == 0)
|
||||
model |= (NC_DISPATCH_NC3 | NC_DISPATCH_NCD);
|
||||
|
||||
done:
|
||||
nc_urlfree(tmpurl);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
@ -110,14 +110,14 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
NC* ncp = NULL;
|
||||
NC_Dispatch* dispatcher = NULL;
|
||||
/* Need three pieces of information for now */
|
||||
int model = 0; /* 3 vs 4 dispatch table */
|
||||
int dap = 0; /* dap vs !dap */
|
||||
int model = 0; /* one of the NC_DISPATCH_XXX values */
|
||||
int isurl = 0; /* dap or cdmremote or neither */
|
||||
int xcmode = 0; /* for implied cmode flags */
|
||||
extern int default_create_format;
|
||||
|
||||
/* Initialize the dispatch table. The function pointers in the
|
||||
* dispatch table will depend on how netCDF was built
|
||||
* (with/without netCDF-4, DAP). */
|
||||
* (with/without netCDF-4, DAP, CDMREMOTE). */
|
||||
if(!nc_initialized)
|
||||
{
|
||||
if ((stat = NC_initialize()))
|
||||
@ -125,11 +125,13 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
nc_initialized = 1;
|
||||
}
|
||||
|
||||
if((dap = NC_testurl(path))) model = NC_urlmodel(path);
|
||||
if((isurl = NC_testurl(path)))
|
||||
model = NC_urlmodel(path);
|
||||
|
||||
/* Look to the incoming cmode for hints */
|
||||
if(model == 0) {
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL) model = 4;
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL)
|
||||
model = NC_DISPATCH_NC4;
|
||||
}
|
||||
|
||||
if(model == 0) {
|
||||
@ -139,11 +141,11 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
#ifdef USE_NETCDF4
|
||||
case NC_FORMAT_NETCDF4:
|
||||
xcmode |= NC_NETCDF4;
|
||||
model = 4;
|
||||
model = NC_DISPATCH_NC4;
|
||||
break;
|
||||
case NC_FORMAT_NETCDF4_CLASSIC:
|
||||
xcmode |= NC_CLASSIC_MODEL;
|
||||
model = 4;
|
||||
model = NC_DISPATCH_NC4;
|
||||
break;
|
||||
#endif
|
||||
case NC_FORMAT_64BIT:
|
||||
@ -151,15 +153,15 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
/* fall thru */
|
||||
case NC_FORMAT_CLASSIC:
|
||||
default:
|
||||
|
||||
model = 3;
|
||||
model = NC_DISPATCH_NC3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Force flag consistentcy */
|
||||
if(model == 4)
|
||||
if(model & NC_DISPATCH_NC4)
|
||||
cmode |= NC_NETCDF4;
|
||||
else if(model == 3) {
|
||||
else if(model & NC_DISPATCH_NC3) {
|
||||
cmode &= ~(NC_NETCDF4 | NC_CLASSIC_MODEL); /* must be netcdf-3 */
|
||||
}
|
||||
|
||||
@ -175,19 +177,30 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
if(dispatcher != NULL) goto havetable;
|
||||
|
||||
/* Figure out what dispatcher to use */
|
||||
dispatcher = NC3_dispatch_table; /* default */
|
||||
#ifdef USE_DAP
|
||||
if(dap) dispatcher = NCD3_dispatch_table; /* default */
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
if(model == 4) {
|
||||
dispatcher = NC4_dispatch_table;
|
||||
#ifdef USE_CDMREMOTE
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
|
||||
dispatcher = NCCR_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_DAP
|
||||
if(dap) dispatcher = NCD4_dispatch_table;
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD4_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
}
|
||||
if(model == (NC_DISPATCH_NC4))
|
||||
dispatcher = NC4_dispatch_table;
|
||||
else
|
||||
#endif /*USE_NETCDF4*/
|
||||
#ifdef USE_DAP
|
||||
if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD3_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
if(model == (NC_DISPATCH_NC3))
|
||||
dispatcher = NC3_dispatch_table;
|
||||
else
|
||||
return NC_ENOTNC;
|
||||
|
||||
havetable:
|
||||
stat = dispatcher->create(path,cmode,initialsz,basepe,chunksizehintp,
|
||||
@ -243,8 +256,8 @@ NC_open(const char *path, int cmode,
|
||||
NC* ncp = NULL;
|
||||
NC_Dispatch* dispatcher = NULL;
|
||||
/* Need two pieces of information for now */
|
||||
int model = 0; /* 3 vs 4 dispatch table */
|
||||
int dap = 0; /* dap vs !dap */
|
||||
int model = 0;
|
||||
int isurl = 0;
|
||||
int cdfversion = 0;
|
||||
int hdfversion = 0;
|
||||
extern int default_create_format;
|
||||
@ -252,17 +265,17 @@ NC_open(const char *path, int cmode,
|
||||
if(!nc_initialized)
|
||||
{stat = NC_initialize(); if(stat) return stat; nc_initialized = 1;}
|
||||
|
||||
if((dap = NC_testurl(path)))
|
||||
if((isurl = NC_testurl(path)))
|
||||
model = NC_urlmodel(path);
|
||||
|
||||
if(dap == 0) {
|
||||
if(isurl == 0) {
|
||||
/* Look at the file if it exists */
|
||||
stat = NC_check_file_type(path,useparallel,mpi_info,&cdfversion,&hdfversion);
|
||||
if(stat == NC_NOERR) {
|
||||
if(hdfversion != 0) {
|
||||
model = 4;
|
||||
model = NC_DISPATCH_NC4;
|
||||
} else if(cdfversion != 0) {
|
||||
model = 3;
|
||||
model = NC_DISPATCH_NC3;
|
||||
}
|
||||
}
|
||||
/* else ignore the file */
|
||||
@ -270,15 +283,15 @@ NC_open(const char *path, int cmode,
|
||||
|
||||
/* Look to the incoming cmode for hints */
|
||||
if(model == 0) {
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL) model = 4;
|
||||
if(cmode & NC_NETCDF4 || cmode & NC_CLASSIC_MODEL) model = NC_DISPATCH_NC4;
|
||||
}
|
||||
|
||||
if(model == 0) model = 3; /* final default */
|
||||
if(model == 0) model = NC_DISPATCH_NC3; /* final default */
|
||||
|
||||
/* Force flag consistentcy */
|
||||
if(model == 4)
|
||||
if(model & NC_DISPATCH_NC4)
|
||||
cmode |= NC_NETCDF4;
|
||||
else if(model == 3) {
|
||||
else if(model & NC_DISPATCH_NC3) {
|
||||
cmode &= ~(NC_NETCDF4 | NC_CLASSIC_MODEL); /* must be netcdf-3 */
|
||||
if(cdfversion == 2) cmode |= NC_64BIT_OFFSET;
|
||||
}
|
||||
@ -291,19 +304,30 @@ NC_open(const char *path, int cmode,
|
||||
if(dispatcher != NULL) goto havetable;
|
||||
|
||||
/* Figure out what dispatcher to use */
|
||||
dispatcher = NC3_dispatch_table; /* default */
|
||||
#ifdef USE_DAP
|
||||
if(dap) dispatcher = NCD3_dispatch_table; /* default */
|
||||
#if defined(USE_CDMREMOTE)
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
|
||||
dispatcher = NCCR_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
if(model == 4) {
|
||||
dispatcher = NC4_dispatch_table;
|
||||
#ifdef USE_DAP
|
||||
if(dap) dispatcher = NCD4_dispatch_table;
|
||||
#if defined(USE_NETCDF4) && defined(USE_DAP)
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD4_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
}
|
||||
#if defined(USE_DAP)
|
||||
if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD3_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#if defined(USE_NETCDF4)
|
||||
if(model == (NC_DISPATCH_NC4))
|
||||
dispatcher = NC4_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
if(model == (NC_DISPATCH_NC3))
|
||||
dispatcher = NC3_dispatch_table;
|
||||
else
|
||||
return NC_ENOTNC;
|
||||
|
||||
havetable:
|
||||
stat = dispatcher->open(path, cmode, basepe, chunksizehintp,
|
||||
|
396
libdispatch/nc_url.c
Normal file
396
libdispatch/nc_url.c
Normal file
@ -0,0 +1,396 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
*********************************************************************/
|
||||
|
||||
#include "ncdispatch.h"
|
||||
#include "nc_url.h"
|
||||
|
||||
#define LBRACKET '['
|
||||
#define RBRACKET ']'
|
||||
|
||||
static NClist* nc_urlparamdecode(char* params0);
|
||||
static NClist* nc_urlparamlookup(NClist* params, const char* clientparam);
|
||||
static void nc_urlparamfree(NClist* params);
|
||||
|
||||
/* Do a simple url parse*/
|
||||
int
|
||||
nc_urlparse(const char* url0, NC_URL** ncurlp)
|
||||
{
|
||||
char* url;
|
||||
char* p;
|
||||
char* p1;
|
||||
int c;
|
||||
NC_URL* ncurl;
|
||||
|
||||
/* accumulate parse points*/
|
||||
char* protocol = NULL;
|
||||
char* params = NULL;
|
||||
char* baseurl = NULL;
|
||||
char* constraint = NULL;
|
||||
char* stop;
|
||||
|
||||
/* copy url and remove all whitespace*/
|
||||
url = strdup(url0);
|
||||
if(url == NULL) return NC_ENOMEM;
|
||||
|
||||
p = url;
|
||||
p1 = url;
|
||||
while((c=*p1++)) {if(c != ' ' && c != '\t') *p++ = c;}
|
||||
*p = '\0';
|
||||
|
||||
p = url;
|
||||
stop = p + strlen(p);
|
||||
|
||||
/* break up the url string into pieces*/
|
||||
if(*p == LBRACKET) {
|
||||
params = p+1;
|
||||
/* find end of the clientparams*/
|
||||
for(;*p;p++) {if(p[0] == RBRACKET && p[1] != LBRACKET) break;}
|
||||
if(*p == 0) return NC_EINVAL; /* malformed client params*/
|
||||
*p = '\0'; /* leave off the trailing rbracket for now */
|
||||
p++; /* move past the params*/
|
||||
}
|
||||
|
||||
baseurl = p;
|
||||
|
||||
/* Note that we dont care what the protocol is ; just collect it */
|
||||
/* find the end of the protocol */
|
||||
p1 = strchr(p,':');
|
||||
if(p1 == NULL || p1 == p) return NC_EINVAL; /* missing protocol*/
|
||||
/* Simulate strndup */
|
||||
protocol = malloc((size_t)(p1-p));
|
||||
if(protocol == NULL) return NC_ENOMEM;
|
||||
strncpy(protocol,p,(p1-p));
|
||||
/* Look for '?' */
|
||||
constraint = strchr(p,'?');
|
||||
if(constraint) {
|
||||
*constraint++ = '\0';
|
||||
}
|
||||
|
||||
/* assemble the component pieces*/
|
||||
ncurl = malloc(sizeof(NC_URL));
|
||||
if(ncurl == NULL) return NC_ENOMEM;
|
||||
memset((void*)ncurl,0,sizeof(NC_URL));
|
||||
|
||||
ncurl->url = nulldup(url0);
|
||||
if(ncurl->url == NULL) return NC_ENOMEM;
|
||||
ncurl->base = nulldup(baseurl);
|
||||
if(ncurl->base == NULL) return NC_ENOMEM;
|
||||
ncurl->protocol = protocol;
|
||||
ncurl->constraint = nulldup(constraint);
|
||||
if(constraint != NULL && ncurl->constraint == NULL) return NC_ENOMEM;
|
||||
nc_urlsetconstraints(ncurl,constraint);
|
||||
if(params != NULL) {
|
||||
ncurl->params = (char*)malloc(1+2+strlen(params));
|
||||
if(ncurl->params == NULL) return NC_ENOMEM;
|
||||
strcpy(ncurl->params,"[");
|
||||
strcat(ncurl->params,params);
|
||||
strcat(ncurl->params,"]");
|
||||
}
|
||||
if(ncurlp) *ncurlp = ncurl;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"urlparse: params=|%s| base=|%s| projection=|%s| selection=|%s|\n",
|
||||
ncurl->params, ncurl->base, ncurl->projection, ncurl->selection);
|
||||
#endif
|
||||
|
||||
free(url);
|
||||
return NC_NOERR;
|
||||
|
||||
}
|
||||
|
||||
/* Call must free the actual url instance.*/
|
||||
void
|
||||
nc_urlfree(NC_URL* ncurl)
|
||||
{
|
||||
if(ncurl == NULL) return;
|
||||
if(ncurl->url != NULL) {free(ncurl->url);}
|
||||
if(ncurl->base != NULL) {free(ncurl->base);}
|
||||
if(ncurl->protocol != NULL) {free(ncurl->protocol);}
|
||||
if(ncurl->constraint != NULL) {free(ncurl->constraint);}
|
||||
if(ncurl->projection != NULL) {free(ncurl->projection);}
|
||||
if(ncurl->selection != NULL) {free(ncurl->selection);}
|
||||
if(ncurl->params != NULL) {free(ncurl->params);}
|
||||
if(ncurl->parammap != NULL) nc_urlparamfree(ncurl->parammap);
|
||||
free(ncurl);
|
||||
}
|
||||
|
||||
/* Replace the constraints */
|
||||
void
|
||||
nc_urlsetconstraints(NC_URL* durl,const char* constraints)
|
||||
{
|
||||
char* proj = NULL;
|
||||
char* select = NULL;
|
||||
const char* p;
|
||||
|
||||
if(durl->projection != NULL) free(durl->projection);
|
||||
if(durl->selection != NULL) free(durl->selection);
|
||||
durl->projection = NULL;
|
||||
durl->selection = NULL;
|
||||
|
||||
if(constraints == NULL || strlen(constraints)==0) return;
|
||||
|
||||
p = constraints;
|
||||
if(p[0] == '?') p++;
|
||||
proj = (char*) p;
|
||||
select = strchr(proj,'&');
|
||||
if(select != NULL) {
|
||||
size_t plen = (select - proj);
|
||||
if(plen == 0) {
|
||||
proj = NULL;
|
||||
} else {
|
||||
proj = (char*)malloc(plen+1);
|
||||
if(proj == NULL) return;
|
||||
memcpy((void*)proj,p,plen);
|
||||
proj[plen] = '\0';
|
||||
}
|
||||
select = nulldup(select);
|
||||
} else {
|
||||
proj = nulldup(proj);
|
||||
select = NULL;
|
||||
}
|
||||
durl->projection = proj;
|
||||
durl->selection = select;
|
||||
}
|
||||
|
||||
int
|
||||
nc_urldecodeparams(NC_URL* ncurl)
|
||||
{
|
||||
int ok = 0;
|
||||
if(ncurl->parammap == NULL && ncurl->params != NULL) {
|
||||
NClist* map = nc_urlparamdecode(ncurl->params);
|
||||
ncurl->parammap = map;
|
||||
ok = 1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*! NULL result => entry not found.
|
||||
Empty value should be represented as a zero length list */
|
||||
NClist*
|
||||
nc_urllookup(NC_URL* durl, const char* clientparam)
|
||||
{
|
||||
/* make sure that durl->parammap exists */
|
||||
if(durl->parammap == NULL) nc_urldecodeparams(durl);
|
||||
return nc_urlparamlookup(durl->parammap,clientparam);
|
||||
}
|
||||
|
||||
/* Convenience: search a list for a given string; NULL if not found */
|
||||
const char*
|
||||
nc_urllookupvalue(NClist* list, const char* value)
|
||||
{
|
||||
int i;
|
||||
if(list == NULL || value == NULL) return NULL;
|
||||
for(i=0;i<nclistlength(list);i++) {
|
||||
char* s = (char*)nclistget(list,i);
|
||||
if(s == NULL) continue;
|
||||
if(strcmp(value,s) == 0) return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/*
|
||||
|
||||
Client parameters are assumed to be one or more instances of
|
||||
bracketed pairs: e.g "[...][...]...". The bracket content
|
||||
in turn is assumed to be a comma separated list of
|
||||
<name>=<value> pairs. e.g. x=y,z=,a=b.
|
||||
The resulting parse is stored in a list where the
|
||||
ith element is the name of the parameter
|
||||
and the i+1'th element is a list
|
||||
of all the occurrences kept in the original order.
|
||||
*/
|
||||
|
||||
static NClist*
|
||||
nc_urlparamdecode(char* params0)
|
||||
{
|
||||
char* cp;
|
||||
char* cq;
|
||||
int c;
|
||||
int i;
|
||||
int nparams;
|
||||
NClist* map = nclistnew();
|
||||
char* params;
|
||||
char* tmp;
|
||||
|
||||
if(params0 == NULL) return map;
|
||||
|
||||
/* Pass 1 is to remove all blanks */
|
||||
params = strdup(params0);
|
||||
cp=params; cq = cp;
|
||||
while((c=*cp++)) {
|
||||
if(c == ' ') cp++; else *cq++ = c;
|
||||
}
|
||||
*cq = '\0';
|
||||
|
||||
/* Pass 2 to replace beginning '[' and ending ']' */
|
||||
if(params[0] == '[')
|
||||
strcpy(params,params+1);
|
||||
if(params[strlen(params)-1] == ']')
|
||||
params[strlen(params)-1] = '\0';
|
||||
|
||||
/* Pass 3 to replace "][" pairs with ','*/
|
||||
cp=params; cq = cp;;
|
||||
while((c=*cp++)) {
|
||||
if(c == RBRACKET && *cp == LBRACKET) {cp++; c = ',';}
|
||||
*cq++ = c;
|
||||
}
|
||||
*cq = '\0';
|
||||
|
||||
/* Pass 4 to break string into pieces and count # of pairs */
|
||||
nparams=0;
|
||||
for(cp=params;(c=*cp);cp++) {
|
||||
if(c == ',') {*cp = '\0'; nparams++;}
|
||||
}
|
||||
nparams++; /* for last one */
|
||||
|
||||
/* Pass 5 to break up each pass into a (name,value) pair*/
|
||||
/* and insert into the param map */
|
||||
/* parameters of the form name name= are converted to name=""*/
|
||||
cp = params;
|
||||
for(i=0;i<nparams;i++) {
|
||||
int j;
|
||||
char* next = cp+strlen(cp)+1; /* save ptr to next pair*/
|
||||
char* vp;
|
||||
NClist* values;
|
||||
/*break up the ith param*/
|
||||
vp = strchr(cp,'=');
|
||||
if(vp != NULL) {*vp = '\0'; vp++;} else {vp = "";}
|
||||
/* Locate any previous name match and get/create the value list*/
|
||||
for(values=NULL,j=0;j<nclistlength(map);j+=2) {
|
||||
if(strcmp(cp,(char*)nclistget(map,j))==0) {
|
||||
values = (NClist*)nclistget(map,j+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(values == NULL) {
|
||||
/*add at end */
|
||||
values = nclistnew();
|
||||
nclistpush(map,(ncelem)nulldup(cp));
|
||||
nclistpush(map,(ncelem)values);
|
||||
}
|
||||
/* Add the value (may result in duplicates */
|
||||
nclistpush(values,(ncelem)nulldup(vp));
|
||||
cp = next;
|
||||
}
|
||||
free(params);
|
||||
return map;
|
||||
}
|
||||
|
||||
/*
|
||||
Lookup the param, if value is non-null, then see
|
||||
if it occurs in the value list
|
||||
*/
|
||||
|
||||
static NClist*
|
||||
nc_urlparamlookup(NClist* params, const char* pname)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL || pname == NULL) return NULL;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* name = (char*)nclistget(params,i);
|
||||
if(strcmp(pname,name)==0) {
|
||||
return (NClist*)nclistget(params,i+1);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
nc_urlparamfree(NClist* params)
|
||||
{
|
||||
int i,j;
|
||||
if(params == NULL) return;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* s = (char*)nclistget(params,i);
|
||||
if(s != NULL) free((void*)s);
|
||||
NClist* values = (NClist*)nclistget(params,i+1);
|
||||
for(j=0;j<nclistlength(values);j++) {
|
||||
s = (char*)nclistget(values,j);
|
||||
if(s != NULL) free((void*)s);
|
||||
}
|
||||
nclistfree(values);
|
||||
}
|
||||
nclistfree(params);
|
||||
}
|
||||
|
||||
void
|
||||
nc_urlsetprotocol(NC_URL* ncurl,const char* newprotocol)
|
||||
{
|
||||
if(ncurl != NULL) {
|
||||
if(ncurl->protocol != NULL) free(ncurl->protocol);
|
||||
ncurl->protocol = nulldup(newprotocol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Delete the entry.
|
||||
return value = 1 => found and deleted;
|
||||
0 => param not found
|
||||
*/
|
||||
static int
|
||||
nc_urlparamdelete(NClist* params, const char* clientparam)
|
||||
{
|
||||
int i,found = 0;
|
||||
if(params == NULL || clientparam == NULL) return 0;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* name = (char*)nclistget(params,i);
|
||||
if(strcmp(clientparam,name)==0) {found=1; break;}
|
||||
}
|
||||
if(found) {
|
||||
nclistremove(params,i+1); /* remove value */
|
||||
nclistremove(params,i); /* remove name */
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
Replace new client param (name,value);
|
||||
return value = 1 => replacement performed
|
||||
0 => insertion performed
|
||||
*/
|
||||
static int
|
||||
nc_urlparamreplace(NClist* params, const char* clientparam, const char* value)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL || clientparam == NULL) return 0;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* name = (char*)nclistget(params,i);
|
||||
if(strcmp(clientparam,name)==0) {
|
||||
nclistinsert(params,i+1,(ncelem)nulldup(value));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
nc_urlparaminsert(params,clientparam,value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Insert new client param (name,value);
|
||||
return value = 1 => not already defined
|
||||
0 => param already defined (no change)
|
||||
*/
|
||||
static int
|
||||
nc_urlparaminsert(NClist* params, const char* clientparam, const char* value)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL || clientparam == NULL) return 0;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* name = (char*)nclistget(params,i);
|
||||
if(strcmp(clientparam,name)==0) return 0;
|
||||
}
|
||||
/* not found, append */
|
||||
nclistpush(params,(ncelem)strdup(clientparam));
|
||||
nclistpush(params,(ncelem)nulldup(value));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
47
libdispatch/nc_url.h
Normal file
47
libdispatch/nc_url.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*********************************************************************
|
||||
* Copyright 2010, UCAR/Unidata
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
*********************************************************************/
|
||||
/* $Id$ */
|
||||
/* $Header$ */
|
||||
|
||||
#ifndef NC_URL_H
|
||||
#define NC_URL_H
|
||||
|
||||
#include "nclist.h"
|
||||
|
||||
/*! This is an open structure meaning
|
||||
it is ok to directly access its fields*/
|
||||
typedef struct NC_URL {
|
||||
char* url; /* as passed by the caller */
|
||||
char* base; /*!< without constraints*/
|
||||
char* protocol;
|
||||
char* constraint;
|
||||
char* projection; /*!< without leading '?'*/
|
||||
char* selection; /*!< with leading '&'*/
|
||||
char* params;
|
||||
NClist* parammap;
|
||||
} NC_URL;
|
||||
|
||||
extern int nc_urlparse(const char* s, NC_URL**);
|
||||
extern void nc_urlfree(NC_URL* nc_url);
|
||||
|
||||
/* Replace the constraints */
|
||||
extern void nc_urlsetconstraints(NC_URL*,const char* constraints);
|
||||
|
||||
/* Replace the protocol */
|
||||
extern void nc_urlsetprotocol(NC_URL*,const char* newprotocol);
|
||||
|
||||
/* Construct a complete URL; caller frees returned string */
|
||||
extern char* nc_urlgeturl(NC_URL*,const char* prefix, const char* suffix, int withconstraints);
|
||||
|
||||
extern int nc_urldecodeparams(NC_URL* nc_url);
|
||||
|
||||
/*! NULL result => entry not found.
|
||||
Empty value should be represented as a zero length list */
|
||||
extern NClist* nc_urllookup(NC_URL*, const char* clientparam);
|
||||
|
||||
/* Convenience: search a list for a given string; NULL if not found */
|
||||
extern const char* nc_urllookupvalue(NClist* list, const char* value);
|
||||
|
||||
#endif /*NC_URL_H*/
|
@ -19,9 +19,7 @@
|
||||
#endif
|
||||
#include "netcdf.h"
|
||||
#include "nc.h"
|
||||
#ifdef USE_DAP
|
||||
#include "dapurl.h"
|
||||
#endif
|
||||
#include "nc_url.h"
|
||||
|
||||
extern int nc_get_vara_ubyte(int ncid, int varid,
|
||||
const size_t* start, const size_t* count,
|
||||
@ -80,11 +78,11 @@ extern int nc_put_vara_ulonglong(int ncid, int varid,
|
||||
|
||||
/**************************************************/
|
||||
/* Define the known classes of dispatchers */
|
||||
|
||||
/* Flags may be or'd => powers of 2*/
|
||||
#define NC_DISPATCH_NC3 1
|
||||
#define NC_DISPATCH_NC4 2
|
||||
#define NC_DISPATCH_NCD3 3
|
||||
#define NC_DISPATCH_NCD4 4
|
||||
#define NC_DISPATCH_NCD 4
|
||||
#define NC_DISPATCH_NCR 8
|
||||
|
||||
/* Define a type for use when doing e.g. nc_get_vara_long, etc. */
|
||||
/* Should matche values in libsrc4/netcdf.h */
|
||||
@ -109,6 +107,9 @@ extern int nc_put_vara_ulonglong(int ncid, int varid,
|
||||
#define ATOMICTYPEMAX NC_DOUBLE
|
||||
#endif
|
||||
|
||||
/* Define an alias for int to indicate an error return */
|
||||
typedef int NCerror;
|
||||
|
||||
/* Define a struct to hold the MPI info so it can be passed down the
|
||||
* call stack. This is used internally by the netCDF library. It
|
||||
* should not be used by netcdf users. */
|
||||
@ -137,6 +138,10 @@ extern NC_Dispatch* NCD3_dispatch_table;
|
||||
extern NC_Dispatch* NCD4_dispatch_table;
|
||||
#endif
|
||||
|
||||
#if defined(USE_CDMREMOTE) && defined(USE_NETCDF4)
|
||||
extern NC_Dispatch* NCCR_dispatch_table;
|
||||
#endif
|
||||
|
||||
/**************************************************/
|
||||
/* Forward */
|
||||
#ifndef USE_NETCDF4
|
||||
@ -324,5 +329,16 @@ extern int NCDAP_urlparse(const char* s, void** dapurl);
|
||||
extern void NCDAP_urlfree(void* dapurl);
|
||||
extern const char* NCDAP_urllookup(void* dapurl, const char* param);
|
||||
|
||||
/* Misc */
|
||||
/* Replacement for strdup (in libsrc) */
|
||||
#ifdef HAVE_STRDUP
|
||||
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
|
||||
#else
|
||||
extern char* nulldup(const char*);
|
||||
#endif
|
||||
|
||||
#define nulllen(s) (s==NULL?0:strlen(s))
|
||||
#define nullstring(s) (s==NULL?"(null)":s)
|
||||
|
||||
#endif /* _DISPATCH_H */
|
||||
|
||||
|
@ -45,8 +45,10 @@ EXTERNC ncelem* nclistdup(NClist*);
|
||||
|
||||
/* Look for value match */
|
||||
EXTERNC int nclistcontains(NClist*, ncelem);
|
||||
|
||||
/* remove duplicates */
|
||||
EXTERNC int nclistunique(NClist*);
|
||||
|
||||
/* Create a clone of a list */
|
||||
EXTERNC NClist* nclistclone(NClist*);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
# This Makefile assembles the correct libnetcdf based on various
|
||||
# configure flags. It is assumed that all the relevant convenience
|
||||
# libraries have been built (e.g. libsrc, libsrc4, libncdap3,
|
||||
# libraries have been built (e.g. libsrc, libsrc4, libncdap3, libcdmr,
|
||||
# libncdap4, fortran).
|
||||
|
||||
AM_LDFLAGS = @EXTERN_LDFLAGS@
|
||||
@ -33,6 +33,7 @@ endif # USE_DAP
|
||||
|
||||
# NetCDF-4 ...
|
||||
if USE_NETCDF4
|
||||
|
||||
AM_CPPFLAGS += -I${top_srcdir}/libsrc4
|
||||
libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
|
||||
|
||||
@ -40,6 +41,12 @@ libnetcdf_la_LIBADD += ${top_builddir}/libsrc4/libnetcdf4.la
|
||||
if USE_DAP
|
||||
libnetcdf_la_LIBADD += ${top_builddir}/libncdap4/libncdap4.la
|
||||
endif # USE_DAP
|
||||
|
||||
# netcdf4+cdmremote
|
||||
if BUILD_CDMREMOTE
|
||||
libnetcdf_la_LIBADD += ${top_builddir}/libcdmr/libnccr.la
|
||||
endif # BUILD_CDMREMOTE
|
||||
|
||||
endif #USE_NETCDF4
|
||||
|
||||
if BUILD_F77
|
||||
|
@ -21,6 +21,10 @@ extern int NCD4_initialize(void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_CDMREMOTE
|
||||
extern int NCCR_initialize(void);
|
||||
#endif
|
||||
|
||||
int
|
||||
NC_initialize(void)
|
||||
{
|
||||
@ -40,6 +44,11 @@ NC_initialize(void)
|
||||
if((stat = NCD4_initialize())) return stat;
|
||||
#endif
|
||||
|
||||
/* cdmremote => netcdf4 */
|
||||
#if defined(BUILD_CDMREMOTE)
|
||||
if((stat = NCCR_initialize())) return stat;
|
||||
#endif
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ NCINCL=-I ../liblib
|
||||
#OCLIB=liboc.a
|
||||
#OCINCL=-I./oc
|
||||
|
||||
LFLAG=-L/upc/share/stdinstall/local/${HOST}/lib
|
||||
LFLAG=-L/upc/share/ed/local/${HOST}/lib
|
||||
|
||||
CURLLIB=-lcurl
|
||||
#HDF5LIB=-lhdf5_hl -lhdf5
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
# We may have to add to these later.
|
||||
DISTCLEANFILES =
|
||||
MAINTAINERCLEANFILES =
|
||||
CLEANFILES =
|
||||
LDADD=
|
||||
|
||||
@ -32,7 +33,7 @@ cetab.c \
|
||||
ceparse.c \
|
||||
celex.c \
|
||||
ncd3dispatch.c ncdap3.c ncdap3a.c getvara3.c \
|
||||
nchashmap.c nclist.c ncbytes.c
|
||||
nchashmap.c
|
||||
|
||||
HDRS=\
|
||||
nccommon.h \
|
||||
@ -49,7 +50,7 @@ dapdump.h \
|
||||
netcdf3l.h \
|
||||
ceparselex.h \
|
||||
cetab.h \
|
||||
nchashmap.h nclist.h ncbytes.h
|
||||
nchashmap.h
|
||||
|
||||
if BUILD_DAP
|
||||
|
||||
@ -72,22 +73,22 @@ AM_CPPFLAGS += -I${top_srcdir}/oc
|
||||
|
||||
AM_CPPFLAGS += @EXTERN_CPPFLAGS@
|
||||
|
||||
LDADD += ${top_builddir}/libncdap3/libncdap3.la
|
||||
|
||||
LDADD += ${top_builddir}/oc/liboc.la
|
||||
LDADD += ${top_builddir}/libncdap3/libncdap3.la \
|
||||
${top_builddir}/oc/liboc.la \
|
||||
${top_builddir}/libdispatch/libdispatch.la
|
||||
|
||||
LDADD += @EXTERN_LDFLAGS@
|
||||
|
||||
# Add a trivial test case to check for undefined references
|
||||
check_PROGRAMS = t_dap
|
||||
check_PROGRAMS = t_dap3
|
||||
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
|
||||
TESTS = t_dap
|
||||
t_dap_SOURCES = t_dap.c stubdap3.c
|
||||
t_dap_LDFLAGS = ${top_builddir}/libsrc/libnetcdf3.la \
|
||||
TESTS = t_dap3
|
||||
t_dap3_SOURCES = t_dap3.c stubdap3.c
|
||||
t_dap3_LDFLAGS = ${top_builddir}/libsrc/libnetcdf3.la \
|
||||
${top_builddir}/libdispatch/libdispatch.la
|
||||
CLEANFILES += t_dap
|
||||
CLEANFILES += t_dap3
|
||||
|
||||
EXTRA_DIST = ce.y
|
||||
EXTRA_DIST = ce.y t_dap.c
|
||||
|
||||
endif # BUILD_DAP
|
||||
|
||||
@ -102,10 +103,18 @@ makece::
|
||||
mv ce.tab.h cetab.h
|
||||
|
||||
# One last thing
|
||||
BUILT_SOURCES = .dodsrc
|
||||
BUILT_SOURCES = .dodsrc t_dap3.c
|
||||
|
||||
.dodsrc:
|
||||
echo "#DODSRC" >.dodsrc
|
||||
|
||||
DISTCLEANFILES += .dodsrc
|
||||
|
||||
t_dap3.c: t_dap.c
|
||||
echo "#define NETCDF3ONLY" > t_dap3.c
|
||||
cat t_dap.c >> t_dap3.c
|
||||
|
||||
MAINTAINERCLEANFILES += t_dap3.c
|
||||
|
||||
test: check
|
||||
|
||||
|
@ -6,9 +6,6 @@
|
||||
#ifndef NCCOMMON_H
|
||||
#define NCCOMMON_H 1
|
||||
|
||||
/* It is important to track error status as coming from nc or oc*/
|
||||
typedef int NCerror; /* OCerror is already defined*/
|
||||
|
||||
/* Mnemonics */
|
||||
#ifndef BOOL
|
||||
#define BOOL int
|
||||
@ -369,16 +366,6 @@ typedef struct CDFnode {
|
||||
/* Give PSEUDOFILE a value */
|
||||
#define PSEUDOFILE "/tmp/pseudofileXXXXXX"
|
||||
|
||||
/* Replacement for strdup (in libsrc) */
|
||||
#ifdef HAVE_STRDUP
|
||||
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
|
||||
#else
|
||||
extern char* nulldup(const char*);
|
||||
#endif
|
||||
|
||||
#define nulllen(s) (s==NULL?0:strlen(s))
|
||||
#define nullstring(s) (s==NULL?"(null)":s)
|
||||
|
||||
/**************************************************/
|
||||
/* Shared procedures */
|
||||
|
||||
|
@ -39,7 +39,7 @@ size_t dapsinglecount3[NC_MAX_VAR_DIMS];
|
||||
|
||||
NC_Dispatch NCD3_dispatch_base = {
|
||||
|
||||
NC_DISPATCH_NCD3,
|
||||
NC_DISPATCH_NC3 | NC_DISPATCH_NCD,
|
||||
|
||||
NCD3_new_nc,
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#STDDIR = /opt/csw
|
||||
#STDDIR = /machine/local
|
||||
STDDIR = /upc/share/stdinstall/local/spock
|
||||
STDDIR = /upc/share/ed/local/spock
|
||||
#NCLIB=../libsrc4/.libs/libnetcdf.a
|
||||
NCLIB=../liblib/.libs/libnetcdf.a
|
||||
HDF5DIR = ${STDDIR}
|
||||
|
@ -6,6 +6,7 @@
|
||||
# $Id: Makefile.am,v 1.18 2010/05/29 18:45:47 dmh Exp $
|
||||
|
||||
DISTCLEANFILES =
|
||||
MAINTAINERCLEANFILES =
|
||||
CLEANFILES =
|
||||
LDADD=
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
@ -30,15 +31,16 @@ noinst_LTLIBRARIES = libncdap4.la
|
||||
# Build convenience library
|
||||
libncdap4_la_SOURCES = $(SRC) $(HDRS)
|
||||
|
||||
AM_CPPFLAGS += -I$(top_srcdir)/libncdap3 \
|
||||
-I$(top_srcdir)/libsrc4 \
|
||||
-I$(top_srcdir)/libsrc
|
||||
AM_CPPFLAGS += -I${top_srcdir}/libdispatch \
|
||||
-I$(top_srcdir)/libncdap3 \
|
||||
-I$(top_srcdir)/libsrc4 \
|
||||
-I$(top_srcdir)/libsrc
|
||||
|
||||
AM_CPPFLAGS += -I${top_srcdir}/oc
|
||||
|
||||
AM_CPPFLAGS += -I${top_srcdir}/libdispatch @EXTERN_CPPFLAGS@
|
||||
AM_CPPFLAGS += @EXTERN_CPPFLAGS@
|
||||
|
||||
# Define the load libraries for stub3
|
||||
# Define the load libraries for stub
|
||||
LDADD += ${top_builddir}/libncdap4/libncdap4.la \
|
||||
${top_builddir}/libncdap3/libncdap3.la \
|
||||
${top_builddir}/libsrc4/libnetcdf4.la \
|
||||
@ -54,22 +56,28 @@ LDADD += ${top_builddir}/oc/liboc.la
|
||||
LDADD += @EXTERN_LDFLAGS@
|
||||
|
||||
# Add a trivial test case to check for undefined references
|
||||
check_PROGRAMS = t_dap
|
||||
check_PROGRAMS = t_dap4
|
||||
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
|
||||
TESTS = t_dap
|
||||
t_dap_SOURCES = t_dap.c stubdap4.c
|
||||
CLEANFILES += t_dap
|
||||
TESTS = t_dap4
|
||||
t_dap4_SOURCES = t_dap4.c stubdap4.c
|
||||
CLEANFILES += t_dap4
|
||||
|
||||
endif # USE_NETCDF4
|
||||
|
||||
endif # BUILD_DAP
|
||||
|
||||
# One last thing
|
||||
BUILT_SOURCES = .dodsrc
|
||||
BUILT_SOURCES = .dodsrc t_dap4.c
|
||||
|
||||
.dodsrc:
|
||||
echo "#DODSRC" >.dodsrc
|
||||
|
||||
DISTCLEANFILES += .dodsrc
|
||||
|
||||
endif # BUILD_DAP
|
||||
t_dap4.c: $(top_srcdir)/libncdap3/t_dap.c
|
||||
cat $(top_srcdir)/libncdap3/t_dap.c >>$(top_srcdir)/libncdap4/t_dap4.c
|
||||
|
||||
MAINTAINERCLEANFILES += t_dap4.c
|
||||
|
||||
test: check
|
||||
|
||||
|
43
libncdap4/env
Normal file
43
libncdap4/env
Normal file
@ -0,0 +1,43 @@
|
||||
set PARMS=""; set ARGS=""; set CON="" ; set CE=""; set OCON=""
|
||||
set PARMS="[log]"
|
||||
|
||||
set F="file:///home/dmh/nc/netcdf-3/ncdap_test/testdata3/synth1"
|
||||
if (1 == 0) then
|
||||
set F="http://dapper.pmel.noaa.gov/dapper/argo/argo_all.cdp"
|
||||
#set CON="&location.LATITUDE<1&location.LATITUDE>-1"
|
||||
set F="http://test.opendap.org:8080/dods/dts/test.03"
|
||||
#set CON="s0,s1"
|
||||
set F="http://oceanwatch.pfeg.noaa.gov/opendap/GLOBEC/GLOBEC_cetaceans"
|
||||
set CON="lat,lon&lat>42.0&lat<=42.5"
|
||||
set CON="number&number>6"
|
||||
set F="http://motherlode.ucar.edu:8080/thredds/dodsC/testdods/in.nc"
|
||||
set F="http://ceda.ac.uk/dap/neodc/casix/seawifs_plankton/data/monthly/PSC_monthly_1998.nc"
|
||||
set F="http://test.opendap.org:8080/dods/dts/test.02"
|
||||
set F="http://test.opendap.org/opendap/data/nc/coads_climatology.nc"
|
||||
set F="file:///home/dmh/nc/netcdf-3/ncdap_test/testdata3/test.PointFile"
|
||||
set F="file:///home/dmh/nc/netcdf-3/ncdap_test/testdata3/synth1"
|
||||
set F="http://dods.ndbc.noaa.gov/thredds/dodsC/data/stdmet/46029/46029h9999.nc"
|
||||
set CON="wind_dir[1:10][0:0][0:0]"
|
||||
endif
|
||||
|
||||
set PARMS="${PARMS}[netcdf4]"
|
||||
set PARMS="${PARMS}[cache]"
|
||||
set PARMS="${PARMS}[show=fetch]"
|
||||
#set PARMS="${PARMS}[compile]"
|
||||
if ( "x$CE" != "x" ) set PARMS="${PARMS}[ce=${CE}]"
|
||||
set PROG="./ncd"
|
||||
#set PROG="../ncdump/.libs/ncdump"
|
||||
set U="${PARMS}$F"
|
||||
if ( "x$CON" != "x" ) set U="${PARMS}$F?$CON"
|
||||
set UALL="${PARMS}$F"
|
||||
#set ARGS="-h $ARGS"
|
||||
#set ARGS="-w $ARGS"
|
||||
#set ARGS="-c $ARGS"
|
||||
set VARGS="--leak-check=full"
|
||||
alias qq "gdb --args $PROG $ARGS '$U'"
|
||||
alias qv "valgrind $VARGS PROG $ARGS '$U'"
|
||||
alias q0 "$PROG $ARGS '$U'"
|
||||
alias qh "$PROG -h $ARGS '$U'"
|
||||
alias qqh "gdb --args $PROG -h $ARGS '$U'"
|
||||
alias qall "$PROG -h $ARGS '${UALL}'"
|
||||
alias qv "valgrind $VARGS $PROG $ARGS '$U'"
|
@ -32,7 +32,7 @@ extern size_t dapsinglecount3[NC_MAX_VAR_DIMS];
|
||||
|
||||
NC_Dispatch NCD4_dispatch_base = {
|
||||
|
||||
NC_DISPATCH_NCD4,
|
||||
NC_DISPATCH_NC4|NC_DISPATCH_NCD,
|
||||
|
||||
NCD4_new_nc,
|
||||
|
||||
|
@ -17,12 +17,14 @@
|
||||
#include "nclist.h"
|
||||
#include "nchashmap.h"
|
||||
|
||||
#include "netcdf.h"
|
||||
#include "ncdispatch.h"
|
||||
#include "nc4internal.h"
|
||||
#include "nc.h"
|
||||
|
||||
#include "oc.h"
|
||||
#include "dapurl.h"
|
||||
|
||||
#include "nc4internal.h"
|
||||
#include "nc.h"
|
||||
#include "netcdf.h"
|
||||
|
||||
#include "nccommon.h"
|
||||
#include "ncdap3.h"
|
||||
|
@ -1,585 +0,0 @@
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#undef GENERATE
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
/* Test (some) internal/external type conversions
|
||||
using following DAP dataset (test.02).
|
||||
Dataset {
|
||||
Byte b[DIMSIZE];
|
||||
Int32 i32[DIMSIZE];
|
||||
UInt32 ui32[DIMSIZE];
|
||||
Int16 i16[DIMSIZE];
|
||||
UInt16 ui16[DIMSIZE];
|
||||
Float32 f32[DIMSIZE];
|
||||
Float64 f64[DIMSIZE];
|
||||
String s[DIMSIZE];
|
||||
Url u[DIMSIZE];
|
||||
} OneDimensionalSimpleArrays;
|
||||
*/
|
||||
|
||||
#define NDIMS 1
|
||||
#define DIMSIZE 25
|
||||
#define STRLEN 64
|
||||
|
||||
#ifndef USE_NETCDF4
|
||||
#define NC_UBYTE 7 /* unsigned 1 byte int */
|
||||
#define NC_USHORT 8 /* unsigned 2-byte int */
|
||||
#define NC_UINT 9 /* unsigned 4-byte int */
|
||||
#define NC_INT64 10 /* signed 8-byte int */
|
||||
#define NC_UINT64 11 /* unsigned 8-byte int */
|
||||
#define NC_STRING 12 /* string */
|
||||
#endif
|
||||
|
||||
|
||||
#define CHECK(expr) check(expr,__FILE__,__LINE__);
|
||||
|
||||
#define COMMA (i==0?"":",")
|
||||
|
||||
#define COMPARE(t1,t2,v1,v2) compare(t1,t2,(void*)v1,(void*)v2,#v2,__FILE__,__LINE__)
|
||||
|
||||
static int fail = 0;
|
||||
|
||||
static void compare(nc_type,nc_type,void*,void*,char*,char*,int);
|
||||
|
||||
static void
|
||||
report(const int i, const char* var, const int line)
|
||||
{
|
||||
fprintf(stdout,"%s mismatch: [%d] file: %s line: %d\n",var,i,__FILE__,line);
|
||||
fail = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
check(int ncstat, char* file, int line)
|
||||
{
|
||||
if(ncstat == NC_NOERR) return;
|
||||
fprintf(stderr,"*** FAIL: %d (%s) at %s:%d\n",
|
||||
ncstat,nc_strerror(ncstat),file,line);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* return 1 if |f1-f2| > 0.05 */
|
||||
static int
|
||||
fdiff(double f1, double f2)
|
||||
{
|
||||
double delta = (f1 - f2);
|
||||
if(delta < 0) delta = - delta;
|
||||
if(delta > 0.05) {
|
||||
fprintf(stdout,"fdiff: %1.3f %1.3f delta=%1.3f\n",f1,f2,delta);
|
||||
}
|
||||
return (delta > 0.05?1:0);
|
||||
}
|
||||
|
||||
static char ch_data[DIMSIZE];
|
||||
static signed char int8_data[DIMSIZE];
|
||||
static unsigned char uint8_data[DIMSIZE];
|
||||
static int int8toint32_data[DIMSIZE];
|
||||
static float int82float32_data[DIMSIZE];
|
||||
static short int16_data[DIMSIZE];
|
||||
static int int16toint32_data[DIMSIZE];
|
||||
static float int162float32_data[DIMSIZE];
|
||||
static int int32_data[DIMSIZE];
|
||||
static float int32tofloat32_data[DIMSIZE];
|
||||
static long int32toilong_data[DIMSIZE];
|
||||
static float float32_data[DIMSIZE];
|
||||
static double float64_data[DIMSIZE];
|
||||
#ifndef USE_NETCDF4
|
||||
static char string3_data[DIMSIZE][STRLEN];
|
||||
#endif
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned char ubyte_data[DIMSIZE];
|
||||
static unsigned short uint16_data[DIMSIZE];
|
||||
static unsigned int uint32_data[DIMSIZE];
|
||||
static long long int32toint64_data[DIMSIZE];
|
||||
static unsigned long long int32touint64_data[DIMSIZE];
|
||||
static char* string4_data[DIMSIZE];
|
||||
static char chartostring4_data[DIMSIZE+1]; /* special case */
|
||||
#endif
|
||||
|
||||
static char ch[DIMSIZE];
|
||||
static signed char int8[DIMSIZE];
|
||||
static unsigned char uint8[DIMSIZE];
|
||||
static short int16[DIMSIZE];
|
||||
static int int32[DIMSIZE];
|
||||
static float float32[DIMSIZE];
|
||||
static double float64[DIMSIZE];
|
||||
static long ilong[DIMSIZE];
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned short uint16[DIMSIZE];
|
||||
static unsigned int uint32[DIMSIZE];
|
||||
static long long int64[DIMSIZE];
|
||||
static unsigned long long uint64[DIMSIZE];
|
||||
static char* string4[DIMSIZE];
|
||||
#else
|
||||
static char string3[DIMSIZE][STRLEN];
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int ncid, varid, ncstat;
|
||||
char* url;
|
||||
char* topsrcdir;
|
||||
size_t len;
|
||||
|
||||
#ifndef USE_NETCDF4
|
||||
int j;
|
||||
#endif
|
||||
|
||||
/* location of our target url: use file// to avoid remote
|
||||
server downtime issues
|
||||
*/
|
||||
|
||||
/* Assume that TESTS_ENVIRONMENT was set */
|
||||
topsrcdir = getenv("TOPSRCDIR");
|
||||
if(topsrcdir == NULL) {
|
||||
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
|
||||
#ifdef DEBUG
|
||||
len += strlen("[log][show=fetch]");
|
||||
#endif
|
||||
url = (char*)malloc(len);
|
||||
url[0] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
strcat(url,"[log][show=fetch]");
|
||||
#endif
|
||||
|
||||
strcat(url,"file://");
|
||||
strcat(url,topsrcdir);
|
||||
strcat(url,"/ncdap_test/testdata3/test.02");
|
||||
|
||||
printf("*** Test: var conversions on URL: %s\n",url);
|
||||
|
||||
/* open file, get varid */
|
||||
#ifdef USE_NETCDF4
|
||||
CHECK(nc_open(url, NC_NOWRITE|NC_NETCDF4, &ncid));
|
||||
#else
|
||||
CHECK(nc_open(url, NC_NOWRITE, &ncid));
|
||||
#endif
|
||||
|
||||
/* extract the string case for netcdf-3*/
|
||||
#ifndef USE_NETCDF4
|
||||
CHECK(nc_inq_varid(ncid, "s", &varid));
|
||||
CHECK(nc_get_var_text(ncid,varid,(char*)string3));
|
||||
#ifdef GENERATE
|
||||
printf("static %s string3_data[DIMSIZE][STRLEN]={","char");
|
||||
for(i=0;i<DIMSIZE;i++) {
|
||||
int j;
|
||||
/* Do simple escape */
|
||||
for(j=0;j<STRLEN;j++) {
|
||||
if(string3[i][j] > 0
|
||||
&& string3[i][j] != '\n'
|
||||
&& string3[i][j] != '\r'
|
||||
&& string3[i][j] != '\t'
|
||||
&&(string3[i][j] < ' ' || string3[i][j] >= '\177'))
|
||||
string3[i][j] = '?';
|
||||
}
|
||||
printf("%s\"%s\"",COMMA,string3[i]);
|
||||
}
|
||||
printf("};\n");
|
||||
#else
|
||||
fprintf(stdout,"*** testing: %s\n","string3");
|
||||
for(i=0;i<DIMSIZE;i++) {
|
||||
for(j=0;j<STRLEN;j++) {
|
||||
if(string3[i][j] != string3_data[i][j]) {report(i,"string3",__LINE__); break;}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_text(ncid,varid,ch));
|
||||
#ifdef GENERATE
|
||||
printf("static %s ch_data[DIMSIZE]={","char");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s'\\%03hho'",COMMA,ch[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_CHAR,NC_CHAR,ch,ch_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_schar(ncid,varid,int8));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int8_data[DIMSIZE]={","signed char");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hhd",COMMA,int8[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_BYTE,NC_BYTE,int8,int8_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_uchar(ncid,varid,uint8));
|
||||
#ifdef GENERATE
|
||||
printf("static %s uint8_data[DIMSIZE]={","unsigned char");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hhu",COMMA,uint8[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_UBYTE,NC_UBYTE,uint8,uint8_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_int(ncid,varid,int32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int8toint32_data[DIMSIZE]={","int");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%d",COMMA,int32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_BYTE,NC_INT,int32,int8toint32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_float(ncid,varid,float32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int82float32_data[DIMSIZE]={","float");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%1.3f",COMMA,float32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_FLOAT,NC_FLOAT,float32,int82float32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i16", &varid));
|
||||
CHECK(nc_get_var_short(ncid,varid,int16));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int16_data[DIMSIZE]={","short");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hd",COMMA,int16[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_SHORT,NC_SHORT,int16,int16_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i16", &varid));
|
||||
CHECK(nc_get_var_int(ncid,varid,int32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int16toint32_data[DIMSIZE]={","int");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%d",COMMA,int32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_SHORT,NC_INT,int32,int16toint32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i16", &varid));
|
||||
CHECK(nc_get_var_float(ncid,varid,float32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int162float32_data[DIMSIZE]={","float");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%1.3f",COMMA,float32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_SHORT,NC_FLOAT,float32,int162float32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid));
|
||||
CHECK(nc_get_var_int(ncid,varid,int32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32_data[DIMSIZE]={","int");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%d",COMMA,int32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_INT,int32,int32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid));
|
||||
CHECK(nc_get_var_float(ncid,varid,float32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32tofloat32_data[DIMSIZE]={","float");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%1.3f",COMMA,float32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_FLOAT,float32,int32tofloat32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid));
|
||||
CHECK(nc_get_var_long(ncid,varid,ilong));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32toilong_data[DIMSIZE]={","long");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%ld",COMMA,ilong[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_NAT,ilong,int32toilong_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "f32", &varid));
|
||||
CHECK(nc_get_var_float(ncid,varid,float32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s float32_data[DIMSIZE]={","float");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%1.3f",COMMA,float32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_FLOAT,NC_FLOAT,float32,float32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "f64", &varid));
|
||||
CHECK(nc_get_var_double(ncid,varid,float64));
|
||||
#ifdef GENERATE
|
||||
printf("static %s float64_data[DIMSIZE]={","double");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%1.3f",COMMA,float64[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_DOUBLE,NC_DOUBLE,float64,float64_data);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_uchar(ncid,varid,uint8));
|
||||
#ifdef GENERATE
|
||||
printf("static %s ubyte_data[DIMSIZE]={","unsigned char");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hhu",COMMA,uint8[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_UBYTE,NC_UBYTE,uint8,ubyte_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "ui16", &varid));
|
||||
CHECK(nc_get_var_ushort(ncid,varid,uint16));
|
||||
#ifdef GENERATE
|
||||
printf("static %s uint16_data[DIMSIZE]={","unsigned short");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hu",COMMA,uint16[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_USHORT,NC_USHORT,uint16,uint16_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "ui32", &varid));
|
||||
CHECK(nc_get_var_uint(ncid,varid,uint32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s uint32_data[DIMSIZE]={","unsigned int");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%u",COMMA,uint32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_UINT,NC_UINT,uint32,uint32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid));
|
||||
CHECK(nc_get_var_longlong(ncid,varid,int64));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32toint64_data[DIMSIZE]={","long long");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%lld",COMMA,int64[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_INT64,int64,int32toint64_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_ulonglong(ncid,varid,uint64));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32touint64_data[DIMSIZE]={","unsigned long long");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%llu",COMMA,uint64[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_UINT64,uint64,int32touint64_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "s", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_string(ncid,varid,string4));
|
||||
#ifdef GENERATE
|
||||
printf("static %s string4_data[DIMSIZE]={","char*");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s\"%s\"",COMMA,string4[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_STRING,NC_STRING,string4,string4_data);
|
||||
#ifdef IGNORE
|
||||
fprintf(stdout,"*** testing: %s\n","string4");
|
||||
for(i=0;i<DIMSIZE;i++) {
|
||||
if(strcmp(string4[i],string4_data[i])!=0)
|
||||
{report(i,"string3",__LINE__); break;}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_string(ncid,varid,string4));
|
||||
#ifdef GENERATE
|
||||
printf("static %s chartostring4_data[DIMSIZE+1]={","char");
|
||||
for(i=0;i<DIMSIZE+1;i++) printf("%s'\\%03o'",COMMA,string4[0][i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_CHAR,NC_STRING,string4,chartostring4_data);
|
||||
#ifdef IGNORE
|
||||
fprintf(stdout,"*** testing: %s\n","chartostring4");
|
||||
if(memcmp((void*)string4[0],(void*)chartostring4_data,DIMSIZE+1)!=0)
|
||||
{report(0,"chartostring4",__LINE__);}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if(fail) {
|
||||
printf("ncstat=%d %s",ncstat,nc_strerror(ncstat));
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char ch_data[DIMSIZE]={'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011','\012','\013','\014','\015','\016','\017','\020','\021','\022','\023','\024','\025','\026','\027','\030'};
|
||||
static signed char int8_data[DIMSIZE]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
|
||||
static unsigned char uint8_data[DIMSIZE]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
|
||||
static int int8toint32_data[DIMSIZE]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
|
||||
static float int82float32_data[DIMSIZE]={0.000,1.000,2.000,3.000,4.000,5.000,6.000,7.000,8.000,9.000,10.000,11.000,12.000,13.000,14.000,15.000,16.000,17.000,18.000,19.000,20.000,21.000,22.000,23.000,24.000};
|
||||
static short int16_data[DIMSIZE]={0,256,512,768,1024,1280,1536,1792,2048,2304,2560,2816,3072,3328,3584,3840,4096,4352,4608,4864,5120,5376,5632,5888,6144};
|
||||
static int int16toint32_data[DIMSIZE]={0,256,512,768,1024,1280,1536,1792,2048,2304,2560,2816,3072,3328,3584,3840,4096,4352,4608,4864,5120,5376,5632,5888,6144};
|
||||
static float int162float32_data[DIMSIZE]={0.000,256.000,512.000,768.000,1024.000,1280.000,1536.000,1792.000,2048.000,2304.000,2560.000,2816.000,3072.000,3328.000,3584.000,3840.000,4096.000,4352.000,4608.000,4864.000,5120.000,5376.000,5632.000,5888.000,6144.000};
|
||||
static int int32_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static float int32tofloat32_data[DIMSIZE]={0.000,2048.000,4096.000,6144.000,8192.000,10240.000,12288.000,14336.000,16384.000,18432.000,20480.000,22528.000,24576.000,26624.000,28672.000,30720.000,32768.000,34816.000,36864.000,38912.000,40960.000,43008.000,45056.000,47104.000,49152.000};
|
||||
static long int32toilong_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static float float32_data[DIMSIZE]={0.000,0.010,0.020,0.030,0.040,0.050,0.060,0.070,0.080,0.090,0.100,0.110,0.120,0.130,0.140,0.149,0.159,0.169,0.179,0.189,0.199,0.208,0.218,0.228,0.238};
|
||||
static double float64_data[DIMSIZE]={1.000,1.000,1.000,1.000,0.999,0.999,0.998,0.998,0.997,0.996,0.995,0.994,0.993,0.992,0.990,0.989,0.987,0.986,0.984,0.982,0.980,0.978,0.976,0.974,0.971};
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned char ubyte_data[DIMSIZE]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
|
||||
static unsigned short uint16_data[DIMSIZE]={0,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,16384,17408,18432,19456,20480,21504,22528,23552,24576};
|
||||
static unsigned int uint32_data[DIMSIZE]={0,4096,8192,12288,16384,20480,24576,28672,32768,36864,40960,45056,49152,53248,57344,61440,65536,69632,73728,77824,81920,86016,90112,94208,98304};
|
||||
static long long int32toint64_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static unsigned long long int32touint64_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static char* string4_data[DIMSIZE]={"This is a data test string (pass 0).","This is a data test string (pass 1).","This is a data test string (pass 2).","This is a data test string (pass 3).","This is a data test string (pass 4).","This is a data test string (pass 5).","This is a data test string (pass 6).","This is a data test string (pass 7).","This is a data test string (pass 8).","This is a data test string (pass 9).","This is a data test string (pass 10).","This is a data test string (pass 11).","This is a data test string (pass 12).","This is a data test string (pass 13).","This is a data test string (pass 14).","This is a data test string (pass 15).","This is a data test string (pass 16).","This is a data test string (pass 17).","This is a data test string (pass 18).","This is a data test string (pass 19).","This is a data test string (pass 20).","This is a data test string (pass 21).","This is a data test string (pass 22).","This is a data test string (pass 23).","This is a data test string (pass 24)."};
|
||||
|
||||
static char chartostring4_data[DIMSIZE+1]={'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011','\012','\013','\014','\015','\016','\017','\020','\021','\022','\023','\024','\025','\026','\027','\030','\000'};
|
||||
#endif
|
||||
|
||||
#ifndef USE_NETCDF4
|
||||
static char string3_data[DIMSIZE][STRLEN]={"This is a data test string (pass 0).","This is a data test string (pass 1).","This is a data test string (pass 2).","This is a data test string (pass 3).","This is a data test string (pass 4).","This is a data test string (pass 5).","This is a data test string (pass 6).","This is a data test string (pass 7).","This is a data test string (pass 8).","This is a data test string (pass 9).","This is a data test string (pass 10).","This is a data test string (pass 11).","This is a data test string (pass 12).","This is a data test string (pass 13).","This is a data test string (pass 14).","This is a data test string (pass 15).","This is a data test string (pass 16).","This is a data test string (pass 17).","This is a data test string (pass 18).","This is a data test string (pass 19).","This is a data test string (pass 20).","This is a data test string (pass 21).","This is a data test string (pass 22).","This is a data test string (pass 23).","This is a data test string (pass 24)."};
|
||||
#endif
|
||||
|
||||
static void
|
||||
compare(nc_type t1, nc_type t2, void* v0, void* vdata0, char* tag,
|
||||
char* file, int line)
|
||||
{
|
||||
int i;
|
||||
fprintf(stdout,"*** testing: %s\n",tag); \
|
||||
|
||||
#ifdef DEBUG
|
||||
#define test \
|
||||
printf("v ="); \
|
||||
for(i=0;i<DIMSIZE;i++) {printf(" %llu",(unsigned long long)v[i]);} \
|
||||
printf("\n"); \
|
||||
printf("vdata ="); \
|
||||
for(i=0;i<DIMSIZE;i++) {printf(" %llu",(unsigned long long)vdata[i]);} \
|
||||
printf("\n"); \
|
||||
for(i=0;i<DIMSIZE;i++) {\
|
||||
if(v[i] != vdata[i]) {report(i,tag,line); break;}\
|
||||
}
|
||||
#define ftest \
|
||||
printf("v ="); \
|
||||
for(i=0;i<DIMSIZE;i++) {printf(" %g",v[i]);} \
|
||||
printf("\n"); \
|
||||
printf("vdata ="); \
|
||||
for(i=0;i<DIMSIZE;i++) {printf(" %g",vdata[i]);} \
|
||||
printf("\n"); \
|
||||
for(i=0;i<DIMSIZE;i++) {\
|
||||
if(fdiff((double)v[i],(double)vdata[i])) {report(i,tag,line); break;}\
|
||||
}
|
||||
#else
|
||||
#define test for(i=0;i<DIMSIZE;i++) {\
|
||||
if(v[i] != vdata[i]) {report(i,tag,line); break;}\
|
||||
}
|
||||
#define ftest for(i=0;i<DIMSIZE;i++) {\
|
||||
if(fdiff((double)v[i],(double)vdata[i])) {report(i,tag,line); break;}\
|
||||
}
|
||||
#endif
|
||||
|
||||
#define setup(T) T* v = (T*)v0; T* vdata = (T*)vdata0;
|
||||
|
||||
#define CASE(nc1,nc2) (nc1*256+nc2)
|
||||
switch(CASE(t1,t2)) {
|
||||
|
||||
default: {
|
||||
printf("unexpected compare: %d %d\n",(int)t1,(int)t2);
|
||||
abort();
|
||||
}
|
||||
|
||||
case CASE(NC_CHAR,NC_CHAR): {
|
||||
setup(char);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_BYTE,NC_BYTE): {
|
||||
setup(signed char);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_SHORT,NC_SHORT): {
|
||||
setup(short);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_INT,NC_INT): {
|
||||
setup(int);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_FLOAT,NC_FLOAT): {
|
||||
setup(float);
|
||||
ftest;
|
||||
} break;
|
||||
case CASE(NC_DOUBLE,NC_DOUBLE): {
|
||||
setup(double);
|
||||
ftest;
|
||||
} break;
|
||||
|
||||
|
||||
/* Mixed comparisons */
|
||||
case CASE(NC_BYTE,NC_INT): {
|
||||
setup(int);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_SHORT,NC_INT): {
|
||||
setup(int);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_SHORT,NC_FLOAT): {
|
||||
setup(float);
|
||||
ftest;
|
||||
} break;
|
||||
case CASE(NC_INT,NC_FLOAT): {
|
||||
setup(float);
|
||||
ftest;
|
||||
} break;
|
||||
|
||||
/* This is an get_var_long case */
|
||||
case CASE(NC_INT,NC_NAT): {
|
||||
setup(long);
|
||||
test;
|
||||
} break;
|
||||
|
||||
case CASE(NC_UBYTE,NC_UBYTE): {
|
||||
setup(unsigned char);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_USHORT,NC_USHORT): {
|
||||
setup(unsigned short);
|
||||
test;
|
||||
} break;
|
||||
case CASE(NC_UINT,NC_UINT): {
|
||||
setup(unsigned int);
|
||||
test;
|
||||
} break;
|
||||
|
||||
/* Mixed cases */
|
||||
case CASE(NC_INT,NC_INT64): {
|
||||
setup(long long);
|
||||
test;
|
||||
} break;
|
||||
|
||||
case CASE(NC_INT,NC_UINT64): {
|
||||
setup(unsigned long long);
|
||||
test;
|
||||
} break;
|
||||
|
||||
case CASE(NC_STRING,NC_STRING):{
|
||||
setup(char*);
|
||||
for(i=0;i<DIMSIZE;i++) {
|
||||
if(strcmp(v[i],vdata[i])!=0) {report(i,tag,line); break;}
|
||||
}
|
||||
} break;
|
||||
|
||||
case CASE(NC_CHAR,NC_STRING):{
|
||||
setup(char*);
|
||||
if(memcmp((void*)v[0],(void*)vdata,DIMSIZE+1)!=0)
|
||||
{report(0,tag,line);}
|
||||
} break;
|
||||
|
||||
} /*switch*/
|
||||
}
|
||||
|
@ -265,7 +265,6 @@ int
|
||||
set_NC_string(NC_string *ncstrp, const char *str)
|
||||
{
|
||||
size_t slen;
|
||||
size_t diff;
|
||||
|
||||
assert(str != NULL && *str != 0);
|
||||
|
||||
|
@ -3859,11 +3859,11 @@ Specify translation to netCDF-4.
|
||||
Turn on logging and send the log output to the specified file.
|
||||
If no file is specified, then output to standard error.
|
||||
@item "[show=...]" das|dds|url
|
||||
This causes information to appear as specific global attributes. The
|
||||
tags may be combined using comma with no spaces
|
||||
(e.g. "show=dds,url"). The currently recognized tags are "dds" to
|
||||
This causes information to appear as specific global attributes.
|
||||
The currently recognized tags are "dds" to
|
||||
display the underlying DDS, "das" similarly, and "url" to display
|
||||
the url used to retrieve the data.
|
||||
This parameter may be specified multiple times (e.g. ``[show=dds][show=url]'').
|
||||
@item "[show=fetch]"
|
||||
This parameter causes the netCDF code to log a copy of the complete
|
||||
url for every HTTP get request. If logging is enabled, then
|
||||
|
@ -19,7 +19,9 @@ AM_CPPFLAGS += -I$(top_builddir)/liblib
|
||||
# Set up the tests; do the .sh first, then .c
|
||||
check_PROGRAMS =
|
||||
TESTS =
|
||||
#TESTS += tst_ncdap3.sh
|
||||
TESTS_ENVIRONMENT=TOPSRCDIR=${abs_top_srcdir}
|
||||
|
||||
TESTS += tst_ncdap3.sh
|
||||
|
||||
if USE_NETCDF4
|
||||
TESTS += tst_ncdap4.sh
|
||||
@ -46,15 +48,16 @@ endif #REMOTE_TESTS
|
||||
if ENABLE_DAP_REMOTE_TESTS
|
||||
|
||||
# Conversion tests
|
||||
test_cvt3_SOURCES = test_cvt.c
|
||||
test_cvt4_SOURCES = test_cvt.c
|
||||
test_varm3_SOURCES = test_varm3.c
|
||||
check_PROGRAMS += test_cvt3 test_varm3 test_cvt4
|
||||
|
||||
#TESTS += test_cvt3 test_varm3
|
||||
|
||||
if USE_NETCDF4
|
||||
test_cvt4_SOURCES = test_cvt.c
|
||||
check_PROGRAMS += test_cvt4
|
||||
TESTS += test_cvt4
|
||||
else
|
||||
test_cvt3_SOURCES = test_cvt.c
|
||||
test_varm3_SOURCES = test_varm3.c
|
||||
check_PROGRAMS += test_cvt3 test_varm3
|
||||
TESTS += test_cvt3 test_varm3
|
||||
endif
|
||||
|
||||
endif ENABLE_DAP_REMOTE_TESTS
|
||||
@ -73,7 +76,5 @@ if USE_NETCDF4
|
||||
CLEANFILES += test_cvt4
|
||||
endif
|
||||
|
||||
test: check
|
||||
|
||||
endif # BUILD_DAP
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
|
||||
#undef GENERATE
|
||||
|
||||
#undef DEBUG
|
||||
@ -91,15 +92,6 @@ static double float64_data[DIMSIZE];
|
||||
#ifndef USE_NETCDF4
|
||||
static char string3_data[DIMSIZE][STRLEN];
|
||||
#endif
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned char ubyte_data[DIMSIZE];
|
||||
static unsigned short uint16_data[DIMSIZE];
|
||||
static unsigned int uint32_data[DIMSIZE];
|
||||
static long long int32toint64_data[DIMSIZE];
|
||||
static unsigned long long int32touint64_data[DIMSIZE];
|
||||
static char* string4_data[DIMSIZE];
|
||||
static char chartostring4_data[DIMSIZE+1]; /* special case */
|
||||
#endif
|
||||
|
||||
static char ch[DIMSIZE];
|
||||
static signed char int8[DIMSIZE];
|
||||
@ -108,40 +100,48 @@ static short int16[DIMSIZE];
|
||||
static int int32[DIMSIZE];
|
||||
static float float32[DIMSIZE];
|
||||
static double float64[DIMSIZE];
|
||||
static char string3[DIMSIZE][STRLEN];
|
||||
static long ilong[DIMSIZE];
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned short uint16[DIMSIZE];
|
||||
static unsigned int uint32[DIMSIZE];
|
||||
static long long int64[DIMSIZE];
|
||||
static unsigned long long uint64[DIMSIZE];
|
||||
static char* string4[DIMSIZE];
|
||||
#ifndef USE_NETCDF4
|
||||
static char string3[DIMSIZE][STRLEN];
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int ncid, varid, ncstat;
|
||||
int ncid, varid, i, j;
|
||||
int ncstat = NC_NOERR;
|
||||
char* url;
|
||||
#ifndef USE_NETCDF4
|
||||
int j;
|
||||
int i;
|
||||
char* topsrcdir;
|
||||
size_t len;
|
||||
|
||||
/* location of our target url: use file// to avoid remote
|
||||
server downtime issues
|
||||
*/
|
||||
|
||||
/* Assume that TESTS_ENVIRONMENT was set */
|
||||
topsrcdir = getenv("TOPSRCDIR");
|
||||
if(topsrcdir == NULL) {
|
||||
fprintf(stderr,"*** FAIL: $abs_top_srcdir not defined: location= %s:%d\n",__FILE__,__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
len = strlen("file://") + strlen(topsrcdir) + strlen("/ncdap_test/testdata3/test.02") + 1;
|
||||
#ifdef DEBUG
|
||||
len += strlen("[log][show=fetch]");
|
||||
#endif
|
||||
url = (char*)malloc(len);
|
||||
url[0] = '\0';
|
||||
|
||||
#ifdef DEBUG
|
||||
strcat(url,"[log][show=fetch]");
|
||||
#endif
|
||||
|
||||
/* location of our target url*/
|
||||
#ifdef DEBUG
|
||||
url = "[log][show=fetch]http://test.opendap.org:8080/dods/dts/test.02";
|
||||
#else
|
||||
url = "http://test.opendap.org:8080/dods/dts/test.02";
|
||||
#endif
|
||||
strcat(url,"file://");
|
||||
strcat(url,topsrcdir);
|
||||
strcat(url,"/ncdap_test/testdata3/test.02");
|
||||
|
||||
printf("*** Test: var conversions on URL: %s\n",url);
|
||||
|
||||
/* open file, get varid */
|
||||
#ifdef USE_NETCDF4
|
||||
CHECK(nc_open(url, NC_NOWRITE|NC_NETCDF4, &ncid));
|
||||
#else
|
||||
CHECK(nc_open(url, NC_NOWRITE, &ncid));
|
||||
#endif
|
||||
|
||||
/* extract the string case for netcdf-3*/
|
||||
#ifndef USE_NETCDF4
|
||||
@ -301,92 +301,6 @@ int main()
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_DOUBLE,NC_DOUBLE,float64,float64_data);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid));
|
||||
CHECK(nc_get_var_uchar(ncid,varid,uint8));
|
||||
#ifdef GENERATE
|
||||
printf("static %s ubyte_data[DIMSIZE]={","unsigned char");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hhu",COMMA,uint8[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_UBYTE,NC_UBYTE,uint8,ubyte_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "ui16", &varid));
|
||||
CHECK(nc_get_var_ushort(ncid,varid,uint16));
|
||||
#ifdef GENERATE
|
||||
printf("static %s uint16_data[DIMSIZE]={","unsigned short");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%hu",COMMA,uint16[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_USHORT,NC_USHORT,uint16,uint16_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "ui32", &varid));
|
||||
CHECK(nc_get_var_uint(ncid,varid,uint32));
|
||||
#ifdef GENERATE
|
||||
printf("static %s uint32_data[DIMSIZE]={","unsigned int");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%u",COMMA,uint32[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_UINT,NC_UINT,uint32,uint32_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid));
|
||||
CHECK(nc_get_var_longlong(ncid,varid,int64));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32toint64_data[DIMSIZE]={","long long");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%lld",COMMA,int64[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_INT64,int64,int32toint64_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "i32", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_ulonglong(ncid,varid,uint64));
|
||||
#ifdef GENERATE
|
||||
printf("static %s int32touint64_data[DIMSIZE]={","unsigned long long");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s%llu",COMMA,uint64[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_INT,NC_UINT64,uint64,int32touint64_data);
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "s", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_string(ncid,varid,string4));
|
||||
#ifdef GENERATE
|
||||
printf("static %s string4_data[DIMSIZE]={","char*");
|
||||
for(i=0;i<DIMSIZE;i++) printf("%s\"%s\"",COMMA,string4[i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_STRING,NC_STRING,string4,string4_data);
|
||||
#ifdef IGNORE
|
||||
fprintf(stdout,"*** testing: %s\n","string4");
|
||||
for(i=0;i<DIMSIZE;i++) {
|
||||
if(strcmp(string4[i],string4_data[i])!=0)
|
||||
{report(i,"string3",__LINE__); break;}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
CHECK(nc_inq_varid(ncid, "b", &varid)); /* deliberate */
|
||||
CHECK(nc_get_var_string(ncid,varid,string4));
|
||||
#ifdef GENERATE
|
||||
printf("static %s chartostring4_data[DIMSIZE+1]={","char");
|
||||
for(i=0;i<DIMSIZE+1;i++) printf("%s'\\%03o'",COMMA,string4[0][i]);
|
||||
printf("};\n");
|
||||
#else
|
||||
COMPARE(NC_CHAR,NC_STRING,string4,chartostring4_data);
|
||||
#ifdef IGNORE
|
||||
fprintf(stdout,"*** testing: %s\n","chartostring4");
|
||||
if(memcmp((void*)string4[0],(void*)chartostring4_data,DIMSIZE+1)!=0)
|
||||
{report(0,"chartostring4",__LINE__);}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
if(fail) {
|
||||
@ -410,17 +324,6 @@ static long int32toilong_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,
|
||||
static float float32_data[DIMSIZE]={0.000,0.010,0.020,0.030,0.040,0.050,0.060,0.070,0.080,0.090,0.100,0.110,0.120,0.130,0.140,0.149,0.159,0.169,0.179,0.189,0.199,0.208,0.218,0.228,0.238};
|
||||
static double float64_data[DIMSIZE]={1.000,1.000,1.000,1.000,0.999,0.999,0.998,0.998,0.997,0.996,0.995,0.994,0.993,0.992,0.990,0.989,0.987,0.986,0.984,0.982,0.980,0.978,0.976,0.974,0.971};
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
static unsigned char ubyte_data[DIMSIZE]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24};
|
||||
static unsigned short uint16_data[DIMSIZE]={0,1024,2048,3072,4096,5120,6144,7168,8192,9216,10240,11264,12288,13312,14336,15360,16384,17408,18432,19456,20480,21504,22528,23552,24576};
|
||||
static unsigned int uint32_data[DIMSIZE]={0,4096,8192,12288,16384,20480,24576,28672,32768,36864,40960,45056,49152,53248,57344,61440,65536,69632,73728,77824,81920,86016,90112,94208,98304};
|
||||
static long long int32toint64_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static unsigned long long int32touint64_data[DIMSIZE]={0,2048,4096,6144,8192,10240,12288,14336,16384,18432,20480,22528,24576,26624,28672,30720,32768,34816,36864,38912,40960,43008,45056,47104,49152};
|
||||
static char* string4_data[DIMSIZE]={"This is a data test string (pass 0).","This is a data test string (pass 1).","This is a data test string (pass 2).","This is a data test string (pass 3).","This is a data test string (pass 4).","This is a data test string (pass 5).","This is a data test string (pass 6).","This is a data test string (pass 7).","This is a data test string (pass 8).","This is a data test string (pass 9).","This is a data test string (pass 10).","This is a data test string (pass 11).","This is a data test string (pass 12).","This is a data test string (pass 13).","This is a data test string (pass 14).","This is a data test string (pass 15).","This is a data test string (pass 16).","This is a data test string (pass 17).","This is a data test string (pass 18).","This is a data test string (pass 19).","This is a data test string (pass 20).","This is a data test string (pass 21).","This is a data test string (pass 22).","This is a data test string (pass 23).","This is a data test string (pass 24)."};
|
||||
|
||||
static char chartostring4_data[DIMSIZE+1]={'\000','\001','\002','\003','\004','\005','\006','\007','\010','\011','\012','\013','\014','\015','\016','\017','\020','\021','\022','\023','\024','\025','\026','\027','\030','\000'};
|
||||
#endif
|
||||
|
||||
#ifndef USE_NETCDF4
|
||||
static char string3_data[DIMSIZE][STRLEN]={"This is a data test string (pass 0).","This is a data test string (pass 1).","This is a data test string (pass 2).","This is a data test string (pass 3).","This is a data test string (pass 4).","This is a data test string (pass 5).","This is a data test string (pass 6).","This is a data test string (pass 7).","This is a data test string (pass 8).","This is a data test string (pass 9).","This is a data test string (pass 10).","This is a data test string (pass 11).","This is a data test string (pass 12).","This is a data test string (pass 13).","This is a data test string (pass 14).","This is a data test string (pass 15).","This is a data test string (pass 16).","This is a data test string (pass 17).","This is a data test string (pass 18).","This is a data test string (pass 19).","This is a data test string (pass 20).","This is a data test string (pass 21).","This is a data test string (pass 22).","This is a data test string (pass 23).","This is a data test string (pass 24)."};
|
||||
#endif
|
||||
|
@ -227,13 +227,13 @@ if test 1 = 1; then
|
||||
if diff -w ${expected}/${x}.dmp results/${x}.dmp
|
||||
then ok=1; else ok=0; fi
|
||||
if test "$ok" = "1" ; then
|
||||
echo "SUCCEED: ${x}"
|
||||
echo "*** PASS: ${x}"
|
||||
passcount=`expr $passcount + 1`
|
||||
elif test $isxfail = 1 ; then
|
||||
echo "XFAIL: ${x}"
|
||||
echo "*** XFAIL: ${x}"
|
||||
xfailcount=`expr $xfailcount + 1`
|
||||
else
|
||||
echo "FAIL: ${x}"
|
||||
echo "*** FAIL: ${x}"
|
||||
failcount=`expr $failcount + 1`
|
||||
fi
|
||||
fi
|
||||
|
@ -102,8 +102,9 @@ nc_inq_parid(int ncid, const char *fullname, int *locidp) {
|
||||
char *parent = strdup(fullname);
|
||||
char *slash = "/"; /* groupname separator */
|
||||
char *last_slash;
|
||||
if(parent == NULL)
|
||||
if(parent == NULL) {
|
||||
CHECK(NC_ENOMEM, strdup);
|
||||
}
|
||||
last_slash = strrchr(parent, '/');
|
||||
if(last_slash == parent) { /* parent is root */
|
||||
free(parent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user