mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-24 16:04:40 +08:00
fixed char datalist bug and did some more dispatch cleanup
This commit is contained in:
parent
fcbea73e18
commit
ea8379719c
@ -179,11 +179,7 @@ check_err(int stat)
|
||||
{
|
||||
if(stat == NC_NOERR) return;
|
||||
fprintf(stderr,"error status returned: (%d) %s\n",stat,
|
||||
#ifdef USE_NETCDF4
|
||||
nc3_strerror(stat)
|
||||
#else
|
||||
nc_strerror(stat)
|
||||
#endif
|
||||
);
|
||||
fail();
|
||||
}
|
||||
|
@ -19,12 +19,3 @@ NC_initialize(void)
|
||||
NCD3_initialize();
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
extern const char* nc3_strerror(int);
|
||||
const char*
|
||||
nc_strerror(int err)
|
||||
{
|
||||
return nc3_strerror(err);
|
||||
}
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@ netcdf.3: $(top_srcdir)/man4/netcdf.m4
|
||||
m4 $(M4FLAGS) $(ARGS_MANPAGE) $? >$@ || rm $@
|
||||
|
||||
# These files are part of the netCDF-3 library.
|
||||
libnetcdf3_la_SOURCES = nc.h error3.c libvers.c string.c v1hpg.c fbits.h ncio.h \
|
||||
libnetcdf3_la_SOURCES = nc.h string.c v1hpg.c fbits.h ncio.h \
|
||||
onstack.h rnd.h utf8proc.c utf8proc.h utf8proc_data.h nclistmgr.c \
|
||||
putget.m4 attr.m4 nc3dispatch.c nc3dispatch.h nc.c var.c dim.c ncx.m4 \
|
||||
ncx.h lookup3.c pstdint.h
|
||||
|
200
libsrc/error3.c
200
libsrc/error3.c
@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Copyright 1993, University Corporation for Atmospheric Research
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
*/
|
||||
/* $Id: error.c,v 1.14 90/02/23 16:08:55 davis Exp */
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "netcdf.h"
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
#include <string.h> /* contains prototype for ansi libc function strerror() */
|
||||
#else
|
||||
#if defined DLL_NETCDF || defined _WIN32_WCE /* define when library is a DLL */
|
||||
/* provide a strerror function for older windows systems */
|
||||
|
||||
char w32_tmp[NC_MAX_NAME];
|
||||
static char *
|
||||
strerror(int errnum)
|
||||
{
|
||||
sprintf(w32_tmp, "Windows: %d", errnum);
|
||||
return w32_tmp;
|
||||
}
|
||||
#else
|
||||
/* provide a strerror function for older unix systems */
|
||||
static char *
|
||||
strerror(int errnum)
|
||||
{
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
|
||||
if(errnum < 0 || errnum >= sys_nerr) return NULL;
|
||||
/* else */
|
||||
return (char *)(sys_errlist[errnum]);
|
||||
}
|
||||
#endif
|
||||
#endif /* NO_STRERROR */
|
||||
|
||||
|
||||
#ifdef vms
|
||||
/* UNTESTED */
|
||||
/*
|
||||
* On the vms system, when a system error occurs which is not
|
||||
* mapped into the unix styled errno values, errno is set EVMSERR
|
||||
* and a VMS error code is set in vaxc$errno.
|
||||
* This routine prints the systems message associated with status return
|
||||
* from a system services call.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <descrip.h>
|
||||
#include <ssdef.h>
|
||||
|
||||
static const char *
|
||||
vms_strerror( int status )
|
||||
{
|
||||
short msglen;
|
||||
static char msgbuf[256];
|
||||
$DESCRIPTOR(message, msgbuf);
|
||||
register ret;
|
||||
|
||||
msgbuf[0] = 0;
|
||||
ret = SYS$GETMSG(status, &msglen, &message, 15, 0);
|
||||
|
||||
if(ret != SS$_BUFFEROVF && ret != SS$_NORMAL) {
|
||||
(void) strcpy(msgbuf, "EVMSERR");
|
||||
}
|
||||
return(msgbuf);
|
||||
}
|
||||
#endif /* vms */
|
||||
|
||||
|
||||
static char unknown[] = "Unknown Error";
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
const char *
|
||||
nc3_strerror(int err)
|
||||
#else
|
||||
const char *
|
||||
nc_strerror(int err)
|
||||
#endif
|
||||
{
|
||||
|
||||
#ifdef vms
|
||||
if(err == EVMSERR)
|
||||
{
|
||||
return vms_strerror(err);
|
||||
}
|
||||
/* else */
|
||||
#endif /* vms */
|
||||
|
||||
if(NC_ISSYSERR(err))
|
||||
{
|
||||
const char *cp = (const char *) strerror(err);
|
||||
if(cp == NULL)
|
||||
return unknown;
|
||||
/* else */
|
||||
return cp;
|
||||
}
|
||||
/* else */
|
||||
|
||||
switch (err) {
|
||||
case NC_NOERR:
|
||||
return "No error";
|
||||
case NC_EBADID:
|
||||
return "NetCDF: Not a valid ID";
|
||||
case NC_ENFILE:
|
||||
return "NetCDF: Too many files open";
|
||||
case NC_EEXIST:
|
||||
return "NetCDF: File exists && NC_NOCLOBBER";
|
||||
case NC_EINVAL:
|
||||
return "NetCDF: Invalid argument";
|
||||
case NC_EPERM:
|
||||
return "NetCDF: Write to read only";
|
||||
case NC_ENOTINDEFINE:
|
||||
return "NetCDF: Operation not allowed in data mode";
|
||||
case NC_EINDEFINE:
|
||||
return "NetCDF: Operation not allowed in define mode";
|
||||
case NC_EINVALCOORDS:
|
||||
return "NetCDF: Index exceeds dimension bound";
|
||||
case NC_EMAXDIMS:
|
||||
return "NetCDF: NC_MAX_DIMS exceeded";
|
||||
case NC_ENAMEINUSE:
|
||||
return "NetCDF: String match to name in use";
|
||||
case NC_ENOTATT:
|
||||
return "NetCDF: Attribute not found";
|
||||
case NC_EMAXATTS:
|
||||
return "NetCDF: NC_MAX_ATTRS exceeded";
|
||||
case NC_EBADTYPE:
|
||||
return "NetCDF: Not a valid data type or _FillValue type mismatch";
|
||||
case NC_EBADDIM:
|
||||
return "NetCDF: Invalid dimension ID or name";
|
||||
case NC_EUNLIMPOS:
|
||||
return "NetCDF: NC_UNLIMITED in the wrong index";
|
||||
case NC_EMAXVARS:
|
||||
return "NetCDF: NC_MAX_VARS exceeded";
|
||||
case NC_ENOTVAR:
|
||||
return "NetCDF: Variable not found";
|
||||
case NC_EGLOBAL:
|
||||
return "NetCDF: Action prohibited on NC_GLOBAL varid";
|
||||
case NC_ENOTNC:
|
||||
return "NetCDF: Unknown file format";
|
||||
case NC_ESTS:
|
||||
return "NetCDF: In Fortran, string too short";
|
||||
case NC_EMAXNAME:
|
||||
return "NetCDF: NC_MAX_NAME exceeded";
|
||||
case NC_EUNLIMIT:
|
||||
return "NetCDF: NC_UNLIMITED size already in use";
|
||||
case NC_ENORECVARS:
|
||||
return "NetCDF: nc_rec op when there are no record vars";
|
||||
case NC_ECHAR:
|
||||
return "NetCDF: Attempt to convert between text & numbers";
|
||||
case NC_EEDGE:
|
||||
return "NetCDF: Start+count exceeds dimension bound";
|
||||
case NC_ESTRIDE:
|
||||
return "NetCDF: Illegal stride";
|
||||
case NC_EBADNAME:
|
||||
return "NetCDF: Name contains illegal characters";
|
||||
case NC_ERANGE:
|
||||
return "NetCDF: Numeric conversion not representable";
|
||||
case NC_ENOMEM:
|
||||
return "NetCDF: Memory allocation (malloc) failure";
|
||||
case NC_EVARSIZE:
|
||||
return "NetCDF: One or more variable sizes violate format constraints";
|
||||
case NC_EDIMSIZE:
|
||||
return "NetCDF: Invalid dimension size";
|
||||
case NC_ETRUNC:
|
||||
return "NetCDF: File likely truncated or possibly corrupted";
|
||||
case NC_EAXISTYPE:
|
||||
return "NetCDF: Illegal axis type";
|
||||
case NC_EDAP:
|
||||
return "NetCDF: DAP failure";
|
||||
case NC_ECURL:
|
||||
return "NetCDF: libcurl failure";
|
||||
case NC_EIO:
|
||||
return "NetCDF: I/O failure";
|
||||
case NC_ENODATA:
|
||||
return "NetCDF: Variable has no data in DAP request";
|
||||
case NC_EDAPSVC:
|
||||
return "NetCDF: DAP server error";
|
||||
case NC_EDAS:
|
||||
return "NetCDF: Malformed or inaccessible DAP DAS";
|
||||
case NC_EDDS:
|
||||
return "NetCDF: Malformed or inaccessible DAP DDS";
|
||||
case NC_EDATADDS:
|
||||
return "NetCDF: Malformed or inaccessible DAP DATADDS";
|
||||
case NC_EDAPURL:
|
||||
return "NetCDF: Malformed DAP URL";
|
||||
case NC_EDAPCONSTRAINT:
|
||||
return "NetCDF: Malformed DAP Constraint";
|
||||
default: break;
|
||||
}
|
||||
/* default */
|
||||
return unknown;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright 1996, University Corporation for Atmospheric Research
|
||||
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
||||
*/
|
||||
/* $Id: libvers.c,v 2.17 2010/05/26 21:43:33 dmh Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/*
|
||||
* A version string. This whole function is not needed in netCDF-4,
|
||||
* which has it's own version of this function.
|
||||
*/
|
||||
#ifndef USE_NETCDF4
|
||||
#define SKIP_LEADING_GARBAGE 33 /* # of chars prior to the actual version */
|
||||
#define XSTRING(x) #x
|
||||
#define STRING(x) XSTRING(x)
|
||||
static const char nc_libvers[] =
|
||||
"\044Id: \100(#) netcdf library version " VERSION " of "__DATE__" "__TIME__" $";
|
||||
|
||||
const char *
|
||||
nc_inq_libvers(void)
|
||||
{
|
||||
return &nc_libvers[SKIP_LEADING_GARBAGE];
|
||||
}
|
||||
|
||||
#else
|
||||
typedef int ignore; /* define at least one symbol */
|
||||
#endif /* USE_NETCDF4*/
|
@ -68,10 +68,6 @@ union getret
|
||||
};
|
||||
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
const char *nc3_strerror(int ncerr);
|
||||
#endif
|
||||
|
||||
static void
|
||||
chkgot(nc_type type, union getret got, double check)
|
||||
{
|
||||
@ -466,14 +462,9 @@ main(int ac, char *av[])
|
||||
ret = nc__open(fname,NC_NOWRITE, &chunksz, &id);
|
||||
if(ret != NC_NOERR)
|
||||
{
|
||||
#ifdef USE_NETCDF4
|
||||
(void) printf("Could not open %s: %s\n", fname,
|
||||
nc3_strerror(ret));
|
||||
#else
|
||||
(void) printf("Could not open %s: %s\n", fname,
|
||||
(void) printf("Could not open %s: %s\n", fname,
|
||||
nc_strerror(ret));
|
||||
#endif
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
(void) printf("reopen id = %d for filename %s\n",
|
||||
id, fname);
|
||||
|
@ -1,20 +1,91 @@
|
||||
netcdf c0 {
|
||||
netcdf ref_tst_chardata {
|
||||
dimensions:
|
||||
Dr = UNLIMITED ;
|
||||
Dr = UNLIMITED ; // (6 currently)
|
||||
D1 = 1 ;
|
||||
D2 = 2 ;
|
||||
D3 = 3 ;
|
||||
// U = UNLIMITED;
|
||||
variables:
|
||||
char c1(D1);
|
||||
char c ;
|
||||
char c1(D1) ;
|
||||
char c2(D2) ;
|
||||
char c2a(D2) ;
|
||||
char c3(D3) ;
|
||||
char c13(D1, D3) ;
|
||||
char c31(D3, D1) ;
|
||||
char c111(D1, D1, D1) ;
|
||||
char c123(D1, D2, D3) ;
|
||||
char c213(D2, D1, D3) ;
|
||||
char c231(D2, D3, D1) ;
|
||||
char cr(Dr) ;
|
||||
char cra(Dr) ;
|
||||
char cr1(Dr, D1) ;
|
||||
char cr2(Dr, D2) ;
|
||||
char cr21(Dr, D2, D1) ;
|
||||
char cr33(Dr, D3, D3) ;
|
||||
data:
|
||||
c1 = "";
|
||||
|
||||
c = "2" ;
|
||||
|
||||
c1 = "" ;
|
||||
|
||||
c2 = "a", "b" ;
|
||||
|
||||
c2a = 'a', 'b' ;
|
||||
|
||||
c3 = "\001\300." ;
|
||||
|
||||
c13 =
|
||||
"\tb\177" ;
|
||||
|
||||
c31 =
|
||||
"+",
|
||||
"-",
|
||||
" " ;
|
||||
|
||||
c111 =
|
||||
"@" ;
|
||||
|
||||
c123 =
|
||||
"one",
|
||||
"2" ;
|
||||
|
||||
c213 =
|
||||
"1",
|
||||
"two" ;
|
||||
|
||||
c231 =
|
||||
"@",
|
||||
"D",
|
||||
"H",
|
||||
"H",
|
||||
"L",
|
||||
"P" ;
|
||||
|
||||
cr = "a","b" ;
|
||||
cr2 = "@", "D", "H", "L" ;
|
||||
cr21 = "@", "D", "H", "L" ;
|
||||
cr33 = "1", "two", "3", "4", "5", "six" ;
|
||||
|
||||
cra = "ab" ;
|
||||
|
||||
cr1 =
|
||||
"x1",
|
||||
"zzzz" ;
|
||||
|
||||
cr2 =
|
||||
"@",
|
||||
"D",
|
||||
"H",
|
||||
"L" ;
|
||||
|
||||
cr21 =
|
||||
"@",
|
||||
"D",
|
||||
"H",
|
||||
"L" ;
|
||||
|
||||
cr33 =
|
||||
"1",
|
||||
"two",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"six" ;
|
||||
}
|
||||
|
@ -9,5 +9,4 @@ variables:
|
||||
char cuu(Dr,D2,U);
|
||||
data:
|
||||
cuu = {{"a","def"}}, {{"xy"}};
|
||||
|
||||
}
|
||||
|
@ -19,13 +19,19 @@ export srcdir
|
||||
export builddir
|
||||
|
||||
KFLAG=1 ; export KFLAG
|
||||
echo "Performing diff tests: k=1"
|
||||
sh ${srcdir}/tst_ncgen4_diff.sh
|
||||
echo "Performing cycle tests: k=1"
|
||||
sh ${srcdir}/tst_ncgen4_cycle.sh
|
||||
KFLAG=3 ; export KFLAG
|
||||
echo "Performing diff tests: k=3"
|
||||
sh ${srcdir}/tst_ncgen4_diff.sh
|
||||
echo "Performing cycle tests: k=3"
|
||||
sh ${srcdir}/tst_ncgen4_cycle.sh
|
||||
KFLAG=4 ; export KFLAG
|
||||
echo "Performing diff tests: k=4"
|
||||
sh ${srcdir}/tst_ncgen4_diff.sh
|
||||
echo "Performing cycle tests: k=4"
|
||||
sh ${srcdir}/tst_ncgen4_cycle.sh
|
||||
exit
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
verbose=0
|
||||
|
||||
if test "x$builddir" = "x"; then builddir=`pwd`; fi
|
||||
@ -21,5 +23,6 @@ export builddir
|
||||
KFLAG=1 ; export KFLAG
|
||||
sh ${srcdir}/tst_ncgen4_diff.sh
|
||||
sh ${srcdir}/tst_ncgen4_cycle.sh
|
||||
exit
|
||||
exit 0
|
||||
|
||||
|
||||
|
@ -16,43 +16,40 @@ echo "*** Cycle testing ncgen with -k${KFLAG}"
|
||||
cd ${RESULTSDIR}
|
||||
for x in ${TESTSET} ; do
|
||||
test $verbose = 1 && echo "*** Testing: ${x}"
|
||||
# determine if we need the specflag set
|
||||
specflag=
|
||||
headflag=
|
||||
for s in ${SPECIALTESTS} ; do
|
||||
if test "x${s}" = "x${x}" ; then specflag="-s"; headflag="-h"; fi
|
||||
done
|
||||
# determine if this is an xfailtest
|
||||
isxfail=
|
||||
for t in ${XFAILTESTS} ; do
|
||||
if test "x${t}" = "x${x}" ; then isxfail=1; fi
|
||||
done
|
||||
rm -f ${x}.nc ${x}.dmp
|
||||
# step 1: use original cdl to build the .nc
|
||||
${builddir}/../ncgen/ncgen -k${KFLAG} -o ${x}.nc ${cdl}/${x}.cdl
|
||||
# step 2: dump .nc file
|
||||
${builddir}/../ncdump/ncdump ${headflag} ${specflag} ${x}.nc > ${x}.dmp
|
||||
# step 3: use ncdump output to (re-)build the .nc
|
||||
rm -f ${x}.nc
|
||||
${builddir}/../ncgen/ncgen -k${KFLAG} -o ${x}.nc ${x}.dmp
|
||||
# step 4: dump .nc file again
|
||||
${builddir}/../ncdump/ncdump ${headflag} ${specflag} ${x}.nc > ${x}.dmp2
|
||||
# compare the two ncdump outputs (silently if XFAIL)
|
||||
if test "x$isxfail" = "x1" -a "x$SHOWXFAILS" = "x" ; then
|
||||
if diff -bw ${x}.dmp ${x}.dmp2 >/dev/null 2>&1 ; then ok=1; else ok=0; fi
|
||||
# determine if we need the specflag set
|
||||
specflag=
|
||||
headflag=
|
||||
for s in ${SPECIALTESTS} ; do
|
||||
if test "x${s}" = "x${x}" ; then specflag="-s"; headflag="-h"; fi
|
||||
done
|
||||
# determine if this is an xfailtest;if so, then no point in running it
|
||||
isxfail=0
|
||||
for t in ${XFAILTESTS} ; do
|
||||
if test "x${t}" = "x${x}" ; then isxfail=1; fi
|
||||
done
|
||||
if test "${isxfail}" = "1"; then
|
||||
echo "xfail test: ${x}: ignored"
|
||||
xfailcount=`expr $xfailcount + 1`
|
||||
else
|
||||
rm -f ${x}.nc ${x}.dmp
|
||||
# step 1: use original cdl to build the .nc
|
||||
${builddir}/../ncgen/ncgen -k${KFLAG} -o ${x}.nc ${cdl}/${x}.cdl
|
||||
# step 2: dump .nc file
|
||||
${builddir}/../ncdump/ncdump ${headflag} ${specflag} ${x}.nc > ${x}.dmp
|
||||
# step 3: use ncdump output to (re-)build the .nc
|
||||
rm -f ${x}.nc
|
||||
${builddir}/../ncgen/ncgen -k${KFLAG} -o ${x}.nc ${x}.dmp
|
||||
# step 4: dump .nc file again
|
||||
${builddir}/../ncdump/ncdump ${headflag} ${specflag} ${x}.nc > ${x}.dmp2
|
||||
# compare the two ncdump outputs
|
||||
if diff -w ${x}.dmp ${x}.dmp2 ; then ok=1; else ok=0; fi
|
||||
fi
|
||||
set +x
|
||||
if test "x$ok" = "x1" ; then
|
||||
test $verbose = 1 && echo "*** SUCCEED: ${x}"
|
||||
passcount=`expr $passcount + 1`
|
||||
elif test "x${isxfail}" = "x1" ; then
|
||||
echo "*** XFAIL: ${x}"
|
||||
xfailcount=`expr $xfailcount + 1`
|
||||
else
|
||||
echo "*** FAIL: ${x}"
|
||||
failcount=`expr $failcount + 1`
|
||||
if test "x$ok" = "x1" ; then
|
||||
test $verbose = 1 && echo "*** SUCCEED: ${x}"
|
||||
passcount=`expr $passcount + 1`
|
||||
else
|
||||
echo "*** FAIL: ${x}"
|
||||
failcount=`expr $failcount + 1`
|
||||
fi
|
||||
fi
|
||||
done
|
||||
cd ..
|
||||
@ -60,7 +57,7 @@ cd ..
|
||||
totalcount=`expr $passcount + $failcount + $xfailcount`
|
||||
okcount=`expr $passcount + $xfailcount`
|
||||
|
||||
echo "*** PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
|
||||
echo "*** PASSED: ${okcount}/${totalcount} ; ${failcount} unexpected failures; ${xfailcount} expected failures ignored"
|
||||
|
||||
if test $failcount -gt 0 ; then
|
||||
exit 1
|
||||
|
@ -55,7 +55,7 @@ cd ..
|
||||
|
||||
totalcount=`expr $passcount + $failcount + $xfailcount`
|
||||
okcount=`expr $passcount + $xfailcount`
|
||||
|
||||
set -x
|
||||
echo "*** PASSED: ${okcount}/${totalcount} ; ${xfailcount} expected failures ; ${failcount} unexpected failures"
|
||||
|
||||
if test $failcount -gt 0 ; then
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
RESULTSDIR="./results"
|
||||
#SHOWXFAILS=1
|
||||
|
||||
@ -77,7 +78,7 @@ SPECIALTESTS3="ref_tst_special_atts3"
|
||||
|
||||
SPECIALTESTS="ref_tst_special_atts ${SPECIALTESTS3}"
|
||||
|
||||
XFAILTESTS="ref_const_test ref_tst_unlim2"
|
||||
XFAILTESTS="ref_const_test ref_tst_unlim2 ref_tst_chardata"
|
||||
|
||||
# Following are generally not run
|
||||
# Because of the size of their output
|
||||
|
@ -1231,6 +1231,8 @@ walkchararray(Symbol* vsym, Datalist* fillsrc)
|
||||
the string and then pad to the dim product
|
||||
*/
|
||||
size_t slabsize = arraylength(dimset);
|
||||
/* If rank is 1, then dont' pad the string */
|
||||
if(rank == 1) lastdimsize = 1;
|
||||
if(!buildcanonicalcharlist(vsym->data,lastdimsize,fillchar,&newcon))
|
||||
return;
|
||||
/* pad to slabsize */
|
||||
|
Loading…
Reference in New Issue
Block a user