mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
Integrated latest changes from trunk
This commit is contained in:
commit
0cdced57ed
@ -76,7 +76,7 @@ WIN32=win32
|
||||
# This is the list of subdirs for which Makefiles will be constructed
|
||||
# and run. ncgen must come before ncdump, because their tests
|
||||
# depend on it.
|
||||
SUBDIRS = include $(H5_TEST_DIR) libdispatch $(OCLIB) libsrc \
|
||||
SUBDIRS = include $(OCLIB) $(H5_TEST_DIR) libdispatch libsrc \
|
||||
$(LIBSRC4_DIR) $(DAP2) $(LIBCDMR) $(LIBRPC) liblib \
|
||||
$(NCGEN3) $(NCGEN) $(NCDUMP) \
|
||||
$(TESTDIRS) \
|
||||
|
5
cf
5
cf
@ -6,8 +6,8 @@ if test $# != 0 ; then
|
||||
cmds=$@
|
||||
fi
|
||||
|
||||
HDF5=1
|
||||
#DAP=1
|
||||
#HDF5=1
|
||||
DAP=1
|
||||
#CDMR=1
|
||||
#RPC=1
|
||||
#PGI=1
|
||||
@ -133,6 +133,7 @@ FLAGS="$FLAGS --enable-logging"
|
||||
#FLAGS="$FLAGS --disable-dap-remote-tests"
|
||||
FLAGS="$FLAGS --disable-doxygen"
|
||||
FLAGS="$FLAGS --enable-logging"
|
||||
#FLAGS="$FLAGS --disable-diskless"
|
||||
|
||||
FLAGS="$FLAGS --disable-shared"
|
||||
#FLAGS="$FLAGS --enable-shared"
|
||||
|
100
configure.ac
100
configure.ac
@ -43,6 +43,20 @@ AC_CONFIG_SRCDIR([libsrc/nc.c])
|
||||
|
||||
AC_MSG_NOTICE([checking user options])
|
||||
|
||||
# If --enable-dll is specified the DLL will be built. This only works
|
||||
# on mingw.
|
||||
AC_MSG_CHECKING([whether a win32 DLL is desired])
|
||||
AC_ARG_ENABLE([dll],
|
||||
[AS_HELP_STRING([--enable-dll],
|
||||
[build a win32 DLL (only works on mingw)])])
|
||||
test "x$enable_dll" = xyes || enable_dll=no
|
||||
AC_MSG_RESULT([$enable_dll])
|
||||
if test "x$enable_dll" = xyes; then
|
||||
AC_DEFINE(DLL_NETCDF, 1, [set this only when building a DLL under MinGW])
|
||||
AC_DEFINE(DLL_EXPORT, 1, [set this only when building a DLL under MinGW])
|
||||
fi
|
||||
AM_CONDITIONAL(BUILD_DLL, [test x$enable_dll = xyes])
|
||||
|
||||
# Did the user specify a default minimum blocksize (NCIO_MINBLOCKSIZE) for posixio?
|
||||
AC_MSG_CHECKING([whether a NCIO_MINBLOCKSIZE was specified])
|
||||
AC_ARG_WITH([minblocksize],
|
||||
@ -244,21 +258,21 @@ fi
|
||||
# See if the user provided us with a curl library
|
||||
# Do an initial lib test for curl, but suppress the default action
|
||||
AC_CHECK_LIB([curl],[curl_easy_setopt],[found_curl=yes],[found_curl=no])
|
||||
|
||||
# If curl is required but there is no curl, then complain
|
||||
if test $require_curl = yes -a $found_curl = no ; then
|
||||
AC_MSG_NOTICE([libcurl not found; disabling remote protocol(s) support])
|
||||
enable_dap=no
|
||||
enable_cdmremote=no
|
||||
enable_rpc=no
|
||||
elif test $require_curl = yes -a $found_curl = yes ; then
|
||||
# Redo the check lib to actually add -lcurl
|
||||
AC_CHECK_LIB([curl], [curl_easy_setopt])
|
||||
if test $require_curl = yes ; then
|
||||
if test $enable_dll = yes ; then
|
||||
AC_MSG_NOTICE([libcurl not found; continuing])
|
||||
elif test $found_curl = no ; then
|
||||
AC_MSG_NOTICE([libcurl not found; disabling remote protocol(s) support])
|
||||
enable_dap=no
|
||||
enable_cdmremote=no
|
||||
enable_rpc=no
|
||||
elif test $found_curl = yes ; then
|
||||
# Redo the check lib to actually add -lcurl
|
||||
AC_CHECK_LIB([curl], [curl_easy_setopt])
|
||||
fi
|
||||
fi
|
||||
|
||||
#AC_SEARCH_LIBS([curl_easy_setopt], [curl], [found_curl=yes],[found_curl=no])
|
||||
|
||||
|
||||
# Default is now to always do the short remote tests
|
||||
AC_MSG_CHECKING([whether dap remote testing should be enabled (default on)])
|
||||
AC_ARG_ENABLE([dap-remote-tests],
|
||||
@ -460,19 +474,6 @@ AC_MSG_RESULT($TEMP_LARGE)
|
||||
#AC_SUBST(TEMP_LARGE)
|
||||
AC_DEFINE_UNQUOTED([TEMP_LARGE], ["$TEMP_LARGE"], [Place to put very large netCDF test files.])
|
||||
|
||||
# If --enable-dll is specified the DLL will be built. This only works
|
||||
# on mingw.
|
||||
AC_MSG_CHECKING([whether a win32 DLL is desired])
|
||||
AC_ARG_ENABLE([dll],
|
||||
[AS_HELP_STRING([--enable-dll],
|
||||
[build a win32 DLL (only works on mingw)])])
|
||||
test "x$enable_dll" = xyes || enable_dll=no
|
||||
AC_MSG_RESULT([$enable_dll])
|
||||
AM_CONDITIONAL(BUILD_DLL, [test x$enable_dll = xyes])
|
||||
if test "x$enable_dll" = xyes; then
|
||||
AC_DEFINE(DLL_NETCDF, 1, [set this only when building a DLL under MinGW])
|
||||
fi
|
||||
|
||||
# According to the autoconf mailing list gurus, we must test for
|
||||
# compilers unconditionally. That is, we can't skip looking for the
|
||||
# fortran compilers, just because the user doesn't want fortran. This
|
||||
@ -559,10 +560,15 @@ AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_TIME
|
||||
AC_CHECK_HEADERS([locale.h stdio.h stdarg.h errno.h ctype.h fcntl.h malloc.h stdlib.h string.h \
|
||||
strings.h unistd.h sys/stat.h getopt.h sys/time.h sys/resource.h])
|
||||
AC_CHECK_HEADERS([locale.h stdio.h stdarg.h errno.h ctype.h fcntl.h malloc.h stdlib.h string.h strings.h unistd.h sys/stat.h getopt.h sys/time.h])
|
||||
AC_FUNC_VPRINTF
|
||||
|
||||
# Do sys/resource.h separately
|
||||
#AC_CHECK_HEADERS([sys/resource.h],[havesysresource=1],[havesysresource=0])
|
||||
#if test "x$enable_dll" != xyes ; then
|
||||
AC_CHECK_HEADERS([sys/resource.h])
|
||||
#fi
|
||||
|
||||
# Check for <stdbool.h> that conforms to C99 requirements
|
||||
AC_HEADER_STDBOOL
|
||||
|
||||
@ -572,10 +578,17 @@ AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr strcat strcpy \
|
||||
mkstemp getpid \
|
||||
getrlimit gettimeofday fsync MPI_Comm_f2c])
|
||||
|
||||
# check for memio support
|
||||
# Does the user want to use NC_DISKLESS?
|
||||
AC_MSG_CHECKING([whether in-memory files are enabled])
|
||||
AC_ARG_ENABLE([diskless],
|
||||
[AS_HELP_STRING([--disable-diskless],
|
||||
[use in-memory (NC_DISKLESS) files])])
|
||||
test "x$enable_diskless" = xno || enable_diskless=yes
|
||||
AC_MSG_RESULT($enable_diskless)
|
||||
|
||||
# check for useful, but not essential, memio support
|
||||
AC_CHECK_FUNCS([memmove getpagesize sysconf])
|
||||
|
||||
# check for mmap support
|
||||
# Does the user want to use the mmap for NC_DISKLESS?
|
||||
AC_MSG_CHECKING([whether mmap will be used for in-memory files])
|
||||
AC_ARG_ENABLE([mmap],
|
||||
@ -584,27 +597,22 @@ AC_ARG_ENABLE([mmap],
|
||||
test "x$enable_mmap" = xyes || enable_mmap=no
|
||||
AC_MSG_RESULT($enable_mmap)
|
||||
|
||||
# check for diskless support
|
||||
# Does the user want diskless support NC_DISKLESS?
|
||||
AC_MSG_CHECKING([whether to use diskless])
|
||||
AC_ARG_ENABLE([diskless],
|
||||
[AS_HELP_STRING([--enable-diskless],
|
||||
[use mmap for in-memory (NC_DISKLESS) files])])
|
||||
test "x$enable_diskless" = xyes || enable_diskless=no
|
||||
AC_MSG_RESULT($enable_diskless)
|
||||
|
||||
# check for mmap and mremap
|
||||
# check for mmap and mremap availability before committing to use mmap
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS([mremap])
|
||||
|
||||
if test "x$ac_cv_func_mmap_fixed_mapped" != xyes -o "x$ac_cv_func_mremap" != xyes ; then
|
||||
echo "mmap function or mremap function is not available: disabling mmap"
|
||||
enable_mmap=no
|
||||
fi
|
||||
|
||||
if test "x$enable_mmap" = xyes; then
|
||||
AC_DEFINE([USE_MMAP], [1], [if true, use mmap for in-memory files])
|
||||
# Setup the diskless and mmap conditionals
|
||||
if test "x$enable_diskless" = xyes ; then
|
||||
AC_DEFINE([USE_DISKLESS], [1], [if true, include NC_DISKLESS code])
|
||||
if test "x$enable_mmap" = xyes; then
|
||||
AC_DEFINE([USE_MMAP], [1], [if true, use mmap for in-memory files])
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(USE_MMAP, [test x$enable_mmap = xyes])
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_DECLS([isnan, isinf, isfinite, signbit],,,[#include <math.h>])
|
||||
@ -629,7 +637,7 @@ if test "x$enable_netcdf_4" = xyes || test "x$enable_dap" = xyes; then
|
||||
opendap with --disable-netcdf-4 --disable-dap, or see config.log for errors.])])
|
||||
fi
|
||||
|
||||
# We need the math library.
|
||||
# We need the math library
|
||||
AC_CHECK_LIB([m], [floor], [],
|
||||
[AC_MSG_ERROR([Can't find or link to the math library.])])
|
||||
|
||||
@ -736,6 +744,8 @@ 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
|
||||
AM_CONDITIONAL(BUILD_RPC, [test "x$enable_rpc" = xyes])
|
||||
AM_CONDITIONAL(BUILD_DISKLESS, [test x$enable_diskless = xyes])
|
||||
AM_CONDITIONAL(BUILD_MMAP, [test x$enable_mmap = xyes])
|
||||
|
||||
# If the machine doesn't have a long long, and we want netCDF-4, then
|
||||
# we've got problems!
|
||||
@ -857,7 +867,3 @@ AC_CONFIG_FILES([Makefile
|
||||
],
|
||||
[test -f nc-config && chmod 755 nc-config])
|
||||
AC_OUTPUT()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -7,8 +7,12 @@
|
||||
#include "ncdap3.h"
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
# ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
# endif
|
||||
#endif
|
||||
#include "dapdump.h"
|
||||
|
||||
|
@ -10,7 +10,9 @@ PARMS="[log]"
|
||||
#PARMS="${PARMS}[wholevar]"
|
||||
#PARMS="${PARMS}[show=fetch]"
|
||||
|
||||
F="file://${TOPDIR}/ncdap_test/testdata3/123bears.nc"
|
||||
F="file://${TOPDIR}/ncdap_test/testdata3/synth1"
|
||||
#F="http://motherlode.ucar.edu:8081/dts/test.02"
|
||||
#F="http://motherlode.ucar.edu:8080/thredds/dodsC/testdods/coads_climatology.nc"
|
||||
|
||||
PROG="./ncd"
|
||||
#PROG="../ncdump/ncdump"
|
||||
|
@ -7,8 +7,12 @@
|
||||
#include "ncdap3.h"
|
||||
|
||||
#ifdef HAVE_GETRLIMIT
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
# ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
# ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "nc3dispatch.h"
|
||||
|
@ -18,11 +18,13 @@ libnetcdf3_la_SOURCES = v1hpg.c onstack.h \
|
||||
nclistmgr.c putget.c attr.c nc3dispatch.c nc.c var.c dim.c ncx.c \
|
||||
ncx.h lookup3.c pstdint.h ncio.c ncio.h
|
||||
|
||||
if USE_MMAP
|
||||
libnetcdf3_la_SOURCES += mmapio.c
|
||||
else
|
||||
libnetcdf3_la_SOURCES += memio.c
|
||||
endif
|
||||
if BUILD_DISKLESS
|
||||
if BUILD_MMAP
|
||||
libnetcdf3_la_SOURCES += mmapio.c
|
||||
else !BUILD_MMAP
|
||||
libnetcdf3_la_SOURCES += memio.c
|
||||
endif !BUILD_MMAP
|
||||
endif BUILD_DISKLESS
|
||||
|
||||
# Does the user want to use ffio, a replacement for posixio for Cray
|
||||
# computers?
|
||||
|
@ -299,6 +299,12 @@ memio_open(const char* path,
|
||||
fd = open(path, oflags, 0, "ctx=stm");
|
||||
#else
|
||||
fd = open(path, oflags, OPENMODE);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
if(fd < 0) {
|
||||
fprintf(stderr,"open failed: file=%s err=",path);
|
||||
perror("");
|
||||
}
|
||||
#endif
|
||||
if(fd < 0) {status = errno; goto unwind_open;}
|
||||
|
||||
@ -447,7 +453,11 @@ memio_close(ncio* nciop, int doUnlink)
|
||||
/* See if the user wants the contents persisted to a file */
|
||||
if(memio->persist) {
|
||||
/* Try to open the file for writing */
|
||||
fd = open(nciop->path, O_WRONLY|O_CREAT|O_TRUNC, OPENMODE);
|
||||
int oflags = O_WRONLY|O_CREAT|O_TRUNC;
|
||||
#ifdef O_BINARY
|
||||
fSet(oflags, O_BINARY);
|
||||
#endif
|
||||
fd = open(nciop->path, oflags, OPENMODE);
|
||||
if(fd >= 0) {
|
||||
/* We need to do multiple writes because there is no
|
||||
guarantee that the amount written will be the full amount */
|
||||
|
@ -24,12 +24,14 @@ extern int ffio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void**
|
||||
extern int ffio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
|
||||
#endif
|
||||
|
||||
#ifdef USE_MMAP
|
||||
extern int mmapio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
|
||||
extern int mmapio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
|
||||
#else
|
||||
extern int memio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
|
||||
extern int memio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
|
||||
#ifdef USE_DISKLESS
|
||||
# ifdef USE_MMAP
|
||||
extern int mmapio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
|
||||
extern int mmapio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
|
||||
# else
|
||||
extern int memio_create(const char*,int,size_t,off_t,size_t,size_t*,ncio**,void** const);
|
||||
extern int memio_open(const char*,int,off_t,size_t,size_t*,ncio**,void** const);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
@ -37,12 +39,13 @@ ncio_create(const char *path, int ioflags, size_t initialsz,
|
||||
off_t igeto, size_t igetsz, size_t *sizehintp,
|
||||
ncio** iopp, void** const mempp)
|
||||
{
|
||||
#ifdef USE_DISKLESS
|
||||
if(fIsSet(ioflags,NC_DISKLESS))
|
||||
|
||||
#ifdef USE_MMAP
|
||||
# ifdef USE_MMAP
|
||||
return mmapio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
#else
|
||||
# else
|
||||
return memio_create(path,ioflags,initialsz,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_FFIO
|
||||
@ -60,13 +63,15 @@ ncio_open(const char *path, int ioflags,
|
||||
/* Diskless open has the following constraints:
|
||||
1. file must be classic version 1 or 2
|
||||
*/
|
||||
#ifdef USE_DISKLESS
|
||||
if(fIsSet(ioflags,NC_DISKLESS)) {
|
||||
#ifdef USE_MMAP
|
||||
return mmapio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
#else
|
||||
return memio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
#endif
|
||||
# ifdef USE_MMAP
|
||||
return mmapio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
# else
|
||||
return memio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_FFIO
|
||||
return ffio_open(path,ioflags,igeto,igetsz,sizehintp,iopp,mempp);
|
||||
#else
|
||||
|
10
mclean
Executable file
10
mclean
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -x
|
||||
find . -name Makefile -exec rm '{}' \;
|
||||
find . -name Makefile.in -exec rm '{}' \;
|
||||
rm m4/*
|
||||
cp /dev/null m4/empty
|
||||
rm configure config.guess config.sub config.h.in
|
||||
rm depcomp ltmain.sh compile missing install-sh
|
||||
rm 1
|
||||
rm ncdump/1
|
@ -44,17 +44,24 @@ endif
|
||||
|
||||
|
||||
# Set up the tests.
|
||||
check_PROGRAMS = $(TESTPROGRAMS) tst_diskless tst_diskless3 tst_diskless4
|
||||
check_PROGRAMS = $(TESTPROGRAMS)
|
||||
|
||||
# Build Diskless test helpers
|
||||
if BUILD_DISKLESS
|
||||
check_PROGRAMS += tst_diskless tst_diskless3 tst_diskless4
|
||||
if USE_NETCDF4
|
||||
check_PROGRAMS += tst_diskless2
|
||||
endif
|
||||
endif
|
||||
|
||||
TESTS = $(TESTPROGRAMS)
|
||||
|
||||
if BUILD_DISKLESS
|
||||
TESTS += run_diskless.sh
|
||||
if LARGE_FILE_TESTS
|
||||
TESTS += run_diskless2.sh
|
||||
endif
|
||||
endif
|
||||
|
||||
# This will run a bunch of the test programs with valgrind, the memory
|
||||
# checking tool. (Valgrind must be present for this to work.)
|
||||
|
@ -302,6 +302,7 @@ main(int argc, char *argv[])
|
||||
else
|
||||
fprintf(stderr, "*** nc_test SUCCESS!!!\n");
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,17 @@
|
||||
/* Global */
|
||||
int diskless = 0;
|
||||
|
||||
#undef ERR
|
||||
#define ERR report(status,__LINE__)
|
||||
|
||||
static int status = NC_NOERR;
|
||||
|
||||
void report(int stat, int lno)
|
||||
{
|
||||
fprintf(stderr,"line: %d ; %s\n",stat,nc_strerror(stat));
|
||||
fflush(stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Test a diskless file with two record vars, which grow, and has
|
||||
* attributes added. */
|
||||
@ -50,11 +61,11 @@ test_two_growing_with_att(const char *testfile)
|
||||
int v, r;
|
||||
|
||||
/* Create a file with one ulimited dimensions, and one var. */
|
||||
if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid[0])) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME2, NC_CHAR, 1, &dimid, &varid[1])) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERR;
|
||||
if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERR;
|
||||
if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid[0]))) ERR;
|
||||
if((status=nc_def_var(ncid, VAR_NAME2, NC_CHAR, 1, &dimid, &varid[1]))) ERR;
|
||||
if((status=nc_close(ncid))) ERR;
|
||||
|
||||
/* Create some phoney data. */
|
||||
for (data[0] = 'a', r = 1; r < MAX_RECS; r++)
|
||||
@ -66,34 +77,35 @@ test_two_growing_with_att(const char *testfile)
|
||||
for (r = 0; r < MAX_RECS; r++)
|
||||
{
|
||||
/* Write one record of var data, a single character. */
|
||||
if (nc_open(testfile, NC_WRITE, &ncid)) ERR;
|
||||
if((status=nc_open(testfile, NC_WRITE, &ncid))) ERR;
|
||||
count[0] = 1;
|
||||
start[0] = r;
|
||||
sprintf(att_name, "a_%d", data[r]);
|
||||
for (v = 0; v < NUM_VARS; v++)
|
||||
{
|
||||
if (nc_put_vara_text(ncid, varid[v], start, count, &data[r])) ERR;
|
||||
if (nc_redef(ncid)) ERR;
|
||||
if (nc_put_att_text(ncid, varid[v], att_name, 1, &data[r])) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
if((status=nc_put_vara_text(ncid, varid[v], start, count, &data[r]))) ERR;
|
||||
if((status=nc_redef(ncid))) ERR;
|
||||
if((status=nc_put_att_text(ncid, varid[v], att_name, 1, &data[r]))) ERR;
|
||||
if((status=nc_enddef(ncid))) ERR;
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
if((status=nc_close(ncid))) ERR;
|
||||
|
||||
/* Reopen the file and check it. */
|
||||
if (nc_open(testfile, NC_DISKLESS|NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq_dimlen(ncid, 0, &len_in)) ERR;
|
||||
if((status=nc_open(testfile, NC_DISKLESS|NC_WRITE, &ncid))) ERR;
|
||||
if((status=nc_inq_dimlen(ncid, 0, &len_in))) ERR;
|
||||
if (len_in != r + 1) ERR;
|
||||
index[0] = r;
|
||||
for (v = 0; v < NUM_VARS; v++)
|
||||
{
|
||||
if (nc_get_var1_text(ncid, varid[v], index, &data_in)) ERR;
|
||||
if((status=nc_get_var1_text(ncid, varid[v], index, &data_in))) ERR;
|
||||
if (data_in != data[r]) ERR;
|
||||
}
|
||||
if (nc_close(ncid)) ERR;
|
||||
if((status=nc_close(ncid))) ERR;
|
||||
} /* Next record. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Test a diskless file with one var and one att. */
|
||||
static int
|
||||
test_one_with_att(const char *testfile)
|
||||
@ -104,37 +116,36 @@ test_one_with_att(const char *testfile)
|
||||
size_t start[NDIMS], count[NDIMS];
|
||||
|
||||
/* Create a file with one ulimited dimensions, and one var. */
|
||||
if (nc_create(testfile, NC_CLOBBER, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid)) ERR;
|
||||
if (nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, 1, &data)) ERR;
|
||||
if (nc_enddef(ncid)) ERR;
|
||||
if((status=nc_create(testfile, NC_CLOBBER, &ncid))) ERR;
|
||||
if((status=nc_def_dim(ncid, DIM1_NAME, NC_UNLIMITED, &dimid))) ERR;
|
||||
if((status=nc_def_var(ncid, VAR_NAME, NC_CHAR, 1, &dimid, &varid))) ERR;
|
||||
if((status=nc_put_att_text(ncid, NC_GLOBAL, ATT_NAME, 1, &data))) ERR;
|
||||
if((status=nc_enddef(ncid))) ERR;
|
||||
|
||||
/* Write one record of var data, a single character. */
|
||||
count[0] = 1;
|
||||
start[0] = 0;
|
||||
if (nc_put_vara_text(ncid, varid, start, count, &data)) ERR;
|
||||
if((status=nc_put_vara_text(ncid, varid, start, count, &data))) ERR;
|
||||
|
||||
/* We're done! */
|
||||
if (nc_close(ncid)) ERR;
|
||||
if((status=nc_close(ncid))) ERR;
|
||||
|
||||
/* Reopen the file and check it. */
|
||||
if (nc_open(testfile, NC_DISKLESS|NC_WRITE, &ncid)) ERR;
|
||||
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
|
||||
if((status=nc_open(testfile, NC_DISKLESS|NC_WRITE, &ncid))) ERR;
|
||||
if((status=nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid))) ERR;
|
||||
if (ndims != 1 && nvars != 1 && natts != 0 && unlimdimid != 0) ERR;
|
||||
if (nc_get_var_text(ncid, varid, &data_in)) ERR;
|
||||
if((status=nc_get_var_text(ncid, varid, &data_in))) ERR;
|
||||
if (data_in != data) ERR;
|
||||
if (nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in)) ERR;
|
||||
if((status=nc_get_att_text(ncid, NC_GLOBAL, ATT_NAME, &data_in))) ERR;
|
||||
if (data_in != data) ERR;
|
||||
if (nc_close(ncid)) ERR;
|
||||
if((status=nc_close(ncid))) ERR;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
diskless = (argc > 1);
|
||||
|
||||
printf("\n*** Testing diskless file: create/modify %s: %s\n",
|
||||
|
@ -2,12 +2,16 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#ifdef HAVE_SYS_TIMES_H
|
||||
# include <sys/times.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h> /* for sysconf */
|
||||
#include <sys/resource.h>
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
#include <nc_tests.h> /* The ERR macro is here... */
|
||||
#include <netcdf.h>
|
||||
|
||||
|
@ -29,16 +29,17 @@ endif
|
||||
test_cvt3_SOURCES = test_cvt.c
|
||||
test_vara_SOURCES = test_vara.c
|
||||
test_partvar_SOURCES = test_partvar.c
|
||||
check_PROGRAMS += t_dap3a test_cvt3 test_vara test_partvar
|
||||
TESTS += t_dap3a test_cvt3 test_vara test_partvar
|
||||
test_varm3_SOURCES = test_varm3.c
|
||||
TESTS += test_varm3
|
||||
check_PROGRAMS += test_varm3
|
||||
|
||||
t_dap3a_SOURCES = t_dap3a.c
|
||||
check_PROGRAMS += t_dap3a
|
||||
|
||||
TESTS += t_dap3a test_cvt3 test_vara test_partvar
|
||||
TESTS += test_varm3
|
||||
TESTS += t_dap3a
|
||||
|
||||
check_PROGRAMS += t_dap3a test_cvt3 test_vara test_partvar
|
||||
check_PROGRAMS += test_varm3
|
||||
check_PROGRAMS += t_dap3a
|
||||
|
||||
endif #ENABLE_DAP_REMOTE_TESTS
|
||||
|
||||
|
||||
@ -95,4 +96,6 @@ BUILT_SOURCES = .dodsrc
|
||||
.dodsrc:
|
||||
echo "#DODSRC" >.dodsrc
|
||||
|
||||
DISTCLEANFILES = .dodsrc
|
||||
DISTCLEANFILES = .dodsrc results/* results
|
||||
|
||||
|
||||
|
@ -130,3 +130,4 @@ EXTRA_DIST += tst_ncgen4_shared.sh tst_ncgen4.sh tst_ncgen4_classic.sh \
|
||||
tst_ncgen4_diff.sh tst_ncgen4_cycle.sh ref_ctest.c ref_ctest64.c
|
||||
|
||||
CLEANFILES += results/*.nc results/*.dmp results/*.dmp2 tmp*.cdl
|
||||
DISTCLEANFILES = results
|
||||
|
@ -29,7 +29,7 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
MSC_EXTRA extern int ncopts; /* netCDF error options */
|
||||
EXTERNL int ncopts; /* netCDF error options */
|
||||
char *testfiles[] = {"nonesuch", "nctest_classic.nc",
|
||||
"nctest_64bit_offset.nc", "nctest_netcdf4.nc"};
|
||||
char *testfile;
|
||||
|
Loading…
Reference in New Issue
Block a user