Merge branch 'master' into fix-warnings

This commit is contained in:
Ward Fisher 2019-01-23 15:12:20 -07:00 committed by GitHub
commit 688c06d50c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 18540 additions and 1873 deletions

View File

@ -1408,8 +1408,13 @@ CHECK_FUNCTION_EXISTS(_filelengthi64 HAVE_FILE_LENGTH_I64)
CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
CHECK_FUNCTION_EXISTS(mremap HAVE_MREMAP)
IF(NOT HAVE_MMMAP OR NOT HAVE_MREMAP)
MESSAGE(WARNING "mmap or mremap not found: disabling MMAP support.")
# Check to see if MAP_ANONYMOUS is defined.
CHECK_C_SOURCE_COMPILES("
#include <sys/mmap.h>
int main() {int x = MAP_ANONYMOUS;}" HAVE_MAPANON)
IF(NOT HAVE_MMMAP OR NOT HAVE_MREMAP OR NOT HAVE_MAPANON)
MESSAGE(WARNING "mmap or mremap or MAP_ANONYMOUS not found: disabling MMAP support.")
SET(ENABLE_MMAP OFF)
ENDIF()
@ -1714,10 +1719,6 @@ add_subdirectory("include")
add_subdirectory(libdispatch)
add_subdirectory(libsrc)
IF(ENABLE_FILTER_TESTING)
add_subdirectory(plugins)
ENDIF()
IF(USE_PNETCDF)
add_subdirectory(libsrcp)
ENDIF(USE_PNETCDF)
@ -1743,6 +1744,10 @@ ENDIF()
add_subdirectory(liblib)
IF(ENABLE_FILTER_TESTING)
add_subdirectory(plugins)
ENDIF()
# For tests and utilities, we are no longer
# exporting symbols but rather importing them.
IF(BUILD_DLL)

3
bootstrap Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
autoreconf -ivf

View File

@ -880,15 +880,24 @@ test "x$enable_mmap" = xyes || enable_mmap=no
AC_MSG_RESULT($enable_mmap)
# check for mmap and mremap availability before committing to use mmap
AC_CHECK_FUNCS([mmap],[have_mmap=yes],[have_mmap=no])
AC_CHECK_FUNCS([mremap],[have_mremap=yes],[have_mremap=no])
have_mmap="$enable_mmap"
AC_CHECK_FUNCS([mmap],[],[have_mmap=no])
AC_CHECK_FUNCS([mremap],[],[have_mmap=no])
# Check for MAP_ANONYMOUS
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[#include <sys/mman.h>],
[[int x = MAP_ANONYMOUS;]])],
[havemapanon=yes],
[havemapanon=no])
AC_MSG_CHECKING([whether MAP_ANONYMOUS is defined])
AC_MSG_RESULT([${havemapanon}])
if test "x$havemapanon" != xyes ; then
have_mmap=no
fi
if test "x$have_mmap" != xyes ; then
echo "mmap function is not available: disabling mmap"
enable_mmap=no
fi
if test "x$have_mremap" != xyes ; then
echo "mremap function is not available: disabling mmap"
echo "mmap functionality is not available: disabling mmap"
enable_mmap=no
fi
@ -1101,7 +1110,7 @@ if test "x$enable_hdf5" = xyes ; then
AC_ARG_ENABLE([parallel4],
[AS_HELP_STRING([--disable-parallel4],
[disable parallel I/O for netcdf-4, even if it's enabled in libhdf5])],
[user_set_parallel4=${enableval}])
[user_set_parallel4=${enableval}]2)
test "x$enable_parallel4" = xno || enable_parallel4=yes
# If user wants parallel IO for netCDF-4, make sure HDF5 can provide it.
@ -1190,13 +1199,12 @@ AC_ARG_ENABLE([erange_fill],
[enable_erange_fill=${enableval}], [enable_erange_fill=auto]
)
dnl Always build with relaxed coord bound checking, to prevent API
dnl incompatibilities between different installs of netCDF.
AC_ARG_ENABLE([zero-length-coord-bound],
[AS_HELP_STRING([--disable-zero-length-coord-bound],
[Disable a more relaxed boundary error check NC_EINVALCOORDS
to allow coordinate start argument equal to dimension size
when argument count is zero. @<:@default: enabled@:>@])],
[enable_zero_length_coord_bound=${enableval}], [enable_zero_length_coord_bound=auto]
)
[Disable relaxed boundary error check. Deprecated. Using this can cause API incompatibilities. This option will be removed in the next release of netCDF.])])
test "x$enable_zero_length_coord_bound" = xno || enable_zero_length_coord_bound=yes
# check PnetCDF's settings on enable_erange_fill and relax_coord_bound
if test "x$enable_pnetcdf" = xyes; then
@ -1226,19 +1234,12 @@ if test "x$enable_pnetcdf" = xyes; then
choke me
#endif]])], [relax_coord_bound_pnetcdf=yes], [relax_coord_bound_pnetcdf=no])
AC_MSG_RESULT([$relax_coord_bound_pnetcdf])
if test "x$enable_zero_length_coord_bound" = xauto ; then
enable_zero_length_coord_bound=$relax_coord_bound_pnetcdf
elif test "$enable_zero_length_coord_bound" != "$relax_coord_bound_pnetcdf"; then
if test "$enable_zero_length_coord_bound" = yes; then
AC_MSG_ERROR([Enabling relax-coord-bound conflicts with PnetCDF setting])
else
AC_MSG_ERROR([Disabling relax-coord-bound conflicts with PnetCDF setting])
fi
if test x"$relax_coord_bound_pnetcdf" != xyes; then
AC_MSG_ERROR([PNetCDF must be built with relax-coord-bound])
fi
else
# default setting
enable_erange_fill=no
enable_zero_length_coord_bound=yes
fi
if test "x$enable_zero_length_coord_bound" = xyes; then

View File

@ -7,6 +7,7 @@
Test the netcdf-4 data building process.
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include "netcdf.h"

View File

@ -3,6 +3,7 @@
DB=1
#X=-x
ANSI=1
#MEM=1
#NOTUIL=1
#FAST=1
@ -36,6 +37,10 @@ if test "x$MEM" = x1 ; then
CFLAGS="-fsanitize=address ${CFLAGS}"
fi
if test "x$ANSI" = x1 ; then
CFLAGS="-ansi ${CFLAGS}"
fi
stddir="/usr/local"
PREFIX=/usr/local

View File

@ -1,7 +1,5 @@
#!/bin/sh
#Q=-q
# This shell gets some sample HDF4 files from the netCDF ftp site for
# testing. Then it runs program tst_interops3 on the test file to
# check that HDF4 reading works.
@ -11,6 +9,9 @@
if test "x$srcdir" = x ; then srcdir=`pwd`; fi
. ../test_common.sh
# Uncomment for quiet wget operation.
#Q=-q
# Get a file from the ftp site; retry several times
getfile() {
FTPFILE="ftp://ftp.unidata.ucar.edu/pub/netcdf/sample_data/hdf4/$1.gz"
@ -18,7 +19,7 @@ getfile() {
for try in 1 2 3 4 ; do # try 4 times
# signal success/failure
if wget -c $Q --passive-ftp $FTPFILE ; then
if wget -c $Q --passive-ftp $FTPFILE || curl -O $FTPFILE ; then
return 0 # got it
fi
echo "wget failed: try $try"

View File

@ -40,10 +40,13 @@ extern "C" {
extern int
NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
void* parameters, NC_Dispatch*, NC*);
void *parameters, NC_Dispatch *, NC *);
extern int
NC_HDF4_close(int ncid);
NC_HDF4_abort(int ncid);
extern int
NC_HDF4_close(int ncid, void *ignore);
extern int
NC_HDF4_inq_format(int ncid, int *formatp);

View File

@ -174,5 +174,11 @@ int nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var,
NC_ATT_INFO_T **att);
/* Find var, doing lazy var metadata read if needed. */
int nc4_hdf5_find_grp_h5_var(int ncid, int varid, NC_FILE_INFO_T **h5,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var);
/* Perform lazy read of the rest of the metadata for a var. */
int nc4_get_var_meta(NC_VAR_INFO_T *var);
#endif /* _HDF5INTERNAL_ */

View File

@ -154,6 +154,8 @@ typedef struct NC_VAR_INFO
nc_bool_t written_to; /* True if variable has data written to it */
struct NC_TYPE_INFO *type_info;
int atts_not_read; /* If true, the atts have not yet been read. */
nc_bool_t meta_read; /* True if this vars metadata has been completely read. */
nc_bool_t coords_read; /* True if this var has hidden coordinates att, and it has been read. */
NCindex *att; /* NCindex<NC_ATT_INFO_T*> */
nc_bool_t no_fill; /* True if no fill value is defined for var */
void *fill_value;

View File

@ -5,19 +5,20 @@
* @internal Contains information for creating provenance
* info and/or displaying provenance info.
*
* It has come to pass that we can't guarantee that this information is
* contained only within netcdf4 files. As a result, we need
* to make printing these hidden attributes available to
* netcdf3 as well.
*
*
* For netcdf4 files, capture state information about the following:
* 1. Global: netcdf library version
* 2. Global: hdf5 library version
* 3. Per file: superblock version
* 4. Per File: was it created by netcdf-4?
* 5. Per file: _NCProperties attribute
*
* @author Dennis Heimbigner, Ward Fisher
It has come to pass that we can't guarantee that this information is
contained only within netcdf4 files. As a result, we need
to make printing these hidden attributes available to
netcdf3 as well.
For netcdf4 files, capture state information about the following:
1. Global: netcdf library version
2. Global: hdf5 library version
3. Per file: superblock version
4. Per File: was it created by netcdf-4?
5. Per file: _NCProperties attribute
*/
#ifndef _NCPROVENANCE_
@ -34,10 +35,8 @@ For netcdf4 files, capture state information about the following:
#define NCPROPSSEP1 '|'
#define NCPROPSSEP2 ','
/* Other hidden attributes */
#define ISNETCDF4ATT "_IsNetcdf4"
#define SUPERBLOCKATT "_SuperblockVersion"
#endif /* _NCPROVENANCE_ */

View File

@ -22,24 +22,12 @@ missing functions should be
defined and missing types defined.
*/
#ifndef HAVE_STRDUP
extern char* strdup(const char*);
#endif
/*
#ifndef HAVE_SSIZE_T
typedef long ssize_t;
#define HAVE_SSIZE_T
#endif
*/
/* handle null arguments */
#ifndef nulldup
#ifdef HAVE_STRDUP
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
#else
char *nulldup(const char* s);
#endif
#endif
#ifdef _MSC_VER
#ifndef HAVE_SSIZE_T
@ -49,15 +37,31 @@ typedef SSIZE_T ssize_t;
#endif
#endif
#ifndef HAVE_STRLCAT
#ifdef _MSC_VER
/* Windows strlcat_s is equivalent to strlcat, but different arg order */
#define strlcat(d,s,n) strcat_s((d),(n),(s))
#else
extern size_t strlcat(char* dst, const char* src, size_t dsize);
/*Warning: Cygwin with -ansi does not define these functions
in its headers.*/
#ifndef _WIN32
#if __STDC__ == 1 /*supposed to be same as -ansi flag */
extern char* strdup(const char*);
#ifndef strlcat
extern size_t strlcat(char*,const char*,size_t);
#endif
#ifndef snprintf
extern int snprintf(char*, size_t, const char*, ...);
#endif
extern int strcasecmp(const char*, const char*);
extern long long int strtoll(const char*, char**, int);
extern unsigned long long int strtoull(const char*, char**, int);
#endif
#endif
#ifdef _WIN32
#define strlcat(d,s,n) strcat_s((d),(n),(s))
#endif
/* handle null arguments */
#ifndef nulldup
#define nulldup(s) ((s)==NULL?NULL:strdup(s))
#endif

View File

@ -76,27 +76,39 @@ nc_findtestserver(const char* path, int isdap4, const char* serverlist)
char** svc;
char url[MAXSERVERURL];
char* match = NULL;
int reportsearch;
if((svclist = parseServers(serverlist))==NULL) {
fprintf(stderr,"cannot parse test server list: %s\n",serverlist);
return NULL;
}
reportsearch = (getenv("NC_REPORTSEARCH") != NULL);
for(svc=svclist;*svc;svc++) {
if(strlen(*svc) == 0)
goto done;
if(path == NULL) path = "";
if(strlen(path) > 0 && path[0] == '/')
path++;
if(reportsearch)
fprintf(stderr,"nc_findtestserver: candidate=%s/%s: found=",*svc,path);
/* Try https: first */
snprintf(url,MAXSERVERURL,"https://%s/%s",*svc,path);
if(ping(url) == NC_NOERR)
{match = strdup(url); goto done;}
if(ping(url) == NC_NOERR) {
if(reportsearch) fprintf(stderr,"yes\n");
match = strdup(url);
goto done;
}
/* Try http: next */
snprintf(url,MAXSERVERURL,"http://%s/%s",*svc,path);
if(ping(url) == NC_NOERR)
{match = strdup(url); goto done;}
if(ping(url) == NC_NOERR) {
if(reportsearch) fprintf(stderr,"yes\n");
match = strdup(url);
goto done;
}
if(reportsearch) fprintf(stderr,"no\n");
}
done:
if(reportsearch) fflush(stderr);
/* Free up the envv list of servers */
if(svclist != NULL) {
char** p;

View File

@ -122,7 +122,7 @@ NCD4_reclaimMeta(NCD4meta* dataset)
for(i=0;i<nclistlength(dataset->allnodes);i++) {
NCD4node* node = (NCD4node*)nclistget(dataset->allnodes,i);
reclaimNode(node);
}
}
nullfree(dataset->error.parseerror);
nullfree(dataset->error.message);
nullfree(dataset->error.context);
@ -193,7 +193,7 @@ build(NCD4meta* builder, NCD4node* root)
case NC_STRUCT:
/* We need to compute the field offsets in order to compute the struct size */
computeOffsets(builder,x);
break;
break;
}
}
@ -279,7 +279,7 @@ buildGroups(NCD4meta* builder, NCD4node* parent)
fprintf(stderr,"build group: %s\n",parent->name);
#endif
/* Define any group level attributes */
if((ret = buildAttributes(builder,parent))) goto done;
if((ret = buildAttributes(builder,parent))) goto done;
for(i=0;i<nclistlength(parent->groups);i++) {
NCD4node* g = (NCD4node*)nclistget(parent->groups,i);
@ -302,7 +302,7 @@ buildDimension(NCD4meta* builder, NCD4node* dim)
NCD4node* group = NCD4_groupFor(dim);
if(dim->dim.isunlimited) {
NCCHECK((nc_def_dim(group->meta.id,dim->name,NC_UNLIMITED,&dim->meta.id)));
} else {
} else {
NCCHECK((nc_def_dim(group->meta.id,dim->name,(size_t)dim->dim.size,&dim->meta.id)));
}
done:
@ -315,7 +315,7 @@ buildEnumeration(NCD4meta* builder, NCD4node* en)
int i,ret = NC_NOERR;
NCD4node* group = NCD4_groupFor(en);
NCCHECK((nc_def_enum(group->meta.id,en->basetype->meta.id,en->name,&en->meta.id)));
for(i=0;i<nclistlength(en->en.econsts);i++) {
for(i=0;i<nclistlength(en->en.econsts);i++) {
NCD4node* ec = (NCD4node*)nclistget(en->en.econsts,i);
NCCHECK((nc_insert_enum(group->meta.id, en->meta.id, ec->name, ec->en.ecvalue.i8)));
}
@ -334,7 +334,7 @@ buildOpaque(NCD4meta* builder, NCD4node* op)
/* Two cases, with and without UCARTAGORIGTYPE */
if(op->nc4.orig.name != NULL) {
name = op->nc4.orig.name;
group = op->nc4.orig.group;
group = op->nc4.orig.group;
}
NCCHECK((nc_def_opaque(group->meta.id,op->opaque.size,name,&op->meta.id)));
done:
@ -384,8 +384,8 @@ static int
buildMetaData(NCD4meta* builder, NCD4node* var)
{
int ret = NC_NOERR;
if((ret = buildAttributes(builder,var))) goto done;
if((ret = buildMaps(builder,var))) goto done;
if((ret = buildAttributes(builder,var))) goto done;
if((ret = buildMaps(builder,var))) goto done;
done:
return THROW(ret);
}
@ -476,7 +476,7 @@ buildStructureType(NCD4meta* builder, NCD4node* structtype)
/* Step 2: See if already defined */
if(nc_inq_typeid(group->meta.id,name,&tid) == NC_NOERR) {/* Already exists */
FAIL(NC_ENAMEINUSE,"Inferred type name conflict",name);
}
}
/* Since netcdf does not support forward references,
we presume all field types are defined */
@ -509,7 +509,7 @@ buildVlenType(NCD4meta* builder, NCD4node* vlentype)
/* See if already defined */
if(nc_inq_typeid(group->meta.id,name,&tid) == NC_NOERR) {/* Already exists */
FAIL(NC_ENAMEINUSE,"Inferred type name conflict",name);
}
}
/* Get the baseline type */
basetype = vlentype->basetype;
@ -533,7 +533,7 @@ buildCompound(NCD4meta* builder, NCD4node* cmpdtype, NCD4node* group, char* name
NCCHECK((nc_def_compound(group->meta.id,(size_t)cmpdtype->meta.memsize,name,&cmpdtype->meta.id)));
/* Step 3: add the fields to type */
for(i=0;i<nclistlength(cmpdtype->vars);i++) {
for(i=0;i<nclistlength(cmpdtype->vars);i++) {
int rank;
int dimsizes[NC_MAX_VAR_DIMS];
NCD4node* field = (NCD4node*)nclistget(cmpdtype->vars,i);
@ -579,7 +579,7 @@ buildAtomicVar(NCD4meta* builder, NCD4node* var)
savevarbyid(group,var);
/* Build attributes and map attributes */
if((ret = buildMetaData(builder,var))) goto done;
if((ret = buildMetaData(builder,var))) goto done;
done:
return THROW(ret);
}
@ -601,7 +601,7 @@ buildStructure(NCD4meta* builder, NCD4node* structvar)
savevarbyid(group,structvar);
/* Build attributes and map attributes WRT the variable */
if((ret = buildMetaData(builder,structvar))) goto done;
if((ret = buildMetaData(builder,structvar))) goto done;
done:
return THROW(ret);
@ -623,7 +623,7 @@ buildSequence(NCD4meta* builder, NCD4node* seq)
savevarbyid(group,seq);
/* Build attributes and map attributes WRT the variable */
if((ret = buildMetaData(builder,seq))) goto done;
if((ret = buildMetaData(builder,seq))) goto done;
done:
return THROW(ret);
@ -682,7 +682,7 @@ getFieldFQN(NCD4node* field, const char* tail)
ncbytescat(fqn,tail);
result = ncbytesextract(fqn);
ncbytesfree(fqn);
return result;
return result;
}
static size_t
@ -755,7 +755,7 @@ compileAttrValues(NCD4meta* builder, NCD4node* attr, void** memoryp, NClist* blo
/* Force type match */
basetype = (attr->basetype = container->basetype);
} else {/* Fail */
FAIL(NC_EBADTYPE,"_FillValue/Variable type mismatch: %s:%s",container->name,attr->name);
FAIL(NC_EBADTYPE,"_FillValue/Variable type mismatch: %s:%s",container->name,attr->name);
}
}
}
@ -962,7 +962,7 @@ markfixedsize(NCD4meta* meta)
if(n->sort != NCD4_TYPE) continue;
switch (n->subsort) {
case NC_STRUCT:
for(j=0;j<nclistlength(n->vars);j++) {
for(j=0;j<nclistlength(n->vars);j++) {
NCD4node* field = (NCD4node*)nclistget(n->vars,j);
if(!field->basetype->meta.isfixedsize) {
fixed = 0;
@ -973,7 +973,7 @@ markfixedsize(NCD4meta* meta)
break;
case NC_ENUM:
n->meta.isfixedsize = 1;
break;
break;
default: /* leave as is */
break;
}
@ -1034,11 +1034,13 @@ computeOffsets(NCD4meta* builder, NCD4node* cmpd)
if(alignment > largestalign)
largestalign = alignment;
/* Add possible padding wrt to previous field */
offset += getpadding(offset,alignment);
offset += getpadding(offset,alignment);
field->meta.offset = offset;
assert(ftype->meta.memsize > 0);
size = ftype->meta.memsize;
/*field->meta.memsize = size;*/
#if 0
field->meta.memsize = size;
#endif
/* Now ultiply by the field dimproduct*/
if(nclistlength(field->dims) > 0) {
d4size_t count = NCD4_dimproduct(field);
@ -1086,7 +1088,7 @@ NCD4_computeTypeSize(NCD4meta* builder, NCD4node* type)
}
break;
default: break; /* ignore */
}
}
type->meta.memsize = size;
return size;
}
@ -1115,7 +1117,7 @@ markdapsize(NCD4meta* meta)
switch (type->subsort) {
case NC_STRUCT:
totalsize = 0;
for(j=0;j<nclistlength(type->vars);j++) {
for(j=0;j<nclistlength(type->vars);j++) {
NCD4node* field = (NCD4node*)nclistget(type->vars,j);
size_t size = field->basetype->meta.dapsize;
if(size == 0) {
@ -1128,17 +1130,17 @@ markdapsize(NCD4meta* meta)
break;
case NC_SEQ:
type->meta.dapsize = 0; /* has no fixed size */
break;
break;
case NC_OPAQUE:
type->meta.dapsize = type->opaque.size;
break;
break;
case NC_ENUM:
type->meta.dapsize = type->basetype->meta.dapsize;
break;
break;
case NC_STRING:
type->meta.dapsize = 0; /* has no fixed size */
break;
default:
break;
default:
assert(type->subsort <= NC_UINT64);
/* Already assigned */
break;
@ -1146,4 +1148,3 @@ markdapsize(NCD4meta* meta)
}
return NC_NOERR;
}

View File

@ -14,6 +14,8 @@
#include <io.h>
#endif
extern int mkstemp(char *template);
#define LBRACKET '['
#define RBRACKET ']'

View File

@ -33,6 +33,10 @@
#endif
#include "ezxml.h"
#ifndef vsnprintf
extern int vsnprintf(char*, size_t, const char*, va_list ap);
#endif
#define EZXML_WS "\t\r\n " /* whitespace*/
#define EZXML_ERRL 128 /* maximum error string length*/

View File

@ -18,13 +18,18 @@ libdispatch_la_CPPFLAGS = ${AM_CPPFLAGS}
libdispatch_la_SOURCES = dparallel.c dcopy.c dfile.c ddim.c datt.c \
dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c \
dvarinq.c dinternal.c ddispatch.c dutf8.c nclog.c dstring.c ncuri.c \
nclist.c ncbytes.c nchashmap.c nctime.c nc.c nclistmgr.c drc.c \
nclist.c ncbytes.c nchashmap.c nctime.c nc.c nclistmgr.c \
dauth.c doffsets.c dwinpath.c dutil.c dreadonly.c dnotnc4.c dnotnc3.c \
crc32.c crc32.h daux.c
# Add the utf8 codebase
libdispatch_la_SOURCES += utf8proc.c utf8proc.h
# The rc code is currently only used by libdap2 and libdap4,
# but in the future, it will be expanded to be used as the
# general .rc file for the netcdf-c library. So, always compile it.
libdispatch_la_SOURCES += drc.c
# Add functions only found in netCDF-4.
if USE_NETCDF4
libdispatch_la_SOURCES += dgroup.c dvlen.c dcompound.c dtype.c denum.c \

View File

@ -12,6 +12,9 @@
#include "config.h"
#include <stdlib.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
@ -26,6 +29,11 @@
#include <unistd.h> /* lseek() */
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
extern int fileno(FILE*);
#include "ncdispatch.h"
#include "netcdf_mem.h"
#include "ncwinpath.h"

View File

@ -7,6 +7,10 @@
*/
#include "config.h"
#include "ncdispatch.h"
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
extern int fileno(FILE*);
/**
Create a netCDF file for parallel I/O.

View File

@ -319,7 +319,7 @@ strdup(const char* s)
*/
#ifndef HAVE_STRLCAT
#ifndef _MSC_VER /* We will use strcat_s */
#ifndef _WIN32 /* We will use strcat_s */
/*
* Appends src to string dst of size dsize (unlike strncat, dsize is the
* full size of dst, not space left). At most dsize-1 characters
@ -327,7 +327,7 @@ strdup(const char* s)
* Returns strlen(src) + MIN(dsize, strlen(initial dst)).
* If retval >= dsize, truncation occurred.
*/
size_t
EXTERNL size_t
strlcat(char* dst, const char* src, size_t dsize)
{
const char *odst = dst;
@ -354,5 +354,5 @@ strlcat(char* dst, const char* src, size_t dsize)
return(dlen + (src - osrc)); /* count does not include NUL */
}
#endif /*!_MSC_VER*/
#endif /*!_WIN32*/
#endif /*!HAVE_STRLCAT*/

View File

@ -25,6 +25,8 @@
#include "nclog.h"
#include "ncwinpath.h"
extern int mkstemp(char *template);
#define NC_MAX_PATH 4096
#define LBRACKET '['

View File

@ -699,10 +699,10 @@ NC_check_nulls(int ncid, int varid, const size_t *start, size_t **count,
{
int i;
if (!(*stride = malloc(varndims * sizeof(size_t))))
if (!(*stride = malloc(varndims * sizeof(ptrdiff_t))))
return NC_ENOMEM;
for (i = 0; i < varndims; i++)
*stride[i] = 1;
(*stride)[i] = 1;
}
return NC_NOERR;

View File

@ -21,6 +21,8 @@
#include "ncexternl.h"
#include "ncwinpath.h"
extern char *realpath(const char *path, char *resolved_path);
#undef PATHFORMAT
/*
@ -155,7 +157,7 @@ static char*
makeabsolute(const char* relpath)
{
char* path = NULL;
#ifdef _MSC_VER
#ifdef _WIN32
path = _fullpath(NULL,relpath,8192);
#else
path = realpath(relpath, NULL);

View File

@ -5,7 +5,6 @@
*********************************************************************/
#include "config.h"
#ifdef _MSC_VER
#include<io.h>
#endif
@ -18,6 +17,8 @@
#include <fcntl.h>
#endif
extern FILE* fdopen(int fd, const char *mode);
#include "nclog.h"
#define PREFIXLEN 8

View File

@ -128,7 +128,7 @@ nc_utf8proc_ssize_t nc_utf8proc_iterate(
*dst = uc;
return 1;
}
/*Must be between 0xc2 and 0xf4 inclusive to be valid */
/* Must be between 0xc2 and 0xf4 inclusive to be valid */
if ((uc - 0xc2) > (0xf4-0xc2)) return UTF8PROC_ERROR_INVALIDUTF8;
if (uc < 0xe0) { /* 2-byte sequence */
/* Must have valid continuation character */

View File

@ -380,7 +380,7 @@ typedef nc_utf8proc_int32_t (*nc_utf8proc_custom_func)(nc_utf8proc_int32_t codep
* Array containing the byte lengths of a UTF-8 encoded codepoint based
* on the first byte.
*/
/*const nc_utf8proc_int8_t nc_utf8proc_utf8class[256]; */
/*const nc_utf8proc_int8_t nc_utf8proc_utf8class[256];*/
/**
* Returns the utf8proc API version as a string MAJOR.MINOR.PATCH

View File

@ -24,7 +24,7 @@ NC_HDF4_open,
NC_RO_redef,
NC_RO__enddef,
NC_RO_sync,
NC_HDF4_close,
NC_HDF4_abort,
NC_HDF4_close,
NC_RO_set_fill,
NC_NOTNC3_inq_base_pe,

View File

@ -662,7 +662,7 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
}
/**
* @internal Close the HDF4 file.
* @internal Abort (close) the HDF4 file.
*
* @param ncid File ID.
*
@ -671,7 +671,23 @@ NC_HDF4_open(const char *path, int mode, int basepe, size_t *chunksizehintp,
* @author Ed Hartnett
*/
int
NC_HDF4_close(int ncid)
NC_HDF4_abort(int ncid)
{
return NC_HDF4_close(ncid, NULL);
}
/**
* @internal Close the HDF4 file.
*
* @param ncid File ID.
* @param ignore Ignore this pointer.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @author Ed Hartnett
*/
int
NC_HDF4_close(int ncid, void *ignore)
{
NC_GRP_INFO_T *grp;
NC *nc;

View File

@ -728,8 +728,61 @@ nc4_rec_grp_HDF5_del(NC_GRP_INFO_T *grp)
}
/**
* @internal Given an ncid and varid, find an att. Lazy reads are done
* as needed.
* @internal Given an ncid and varid, get pointers to the group and var
* metadata. Lazy var metadata reads are done as needed.
*
* @param ncid File ID.
* @param varid Variable ID.
* @param h5 Pointer that gets pointer to the NC_FILE_INFO_T struct
* for this file. Ignored if NULL.
* @param grp Pointer that gets pointer to group info. Ignored if
* NULL.
* @param var Pointer that gets pointer to var info. Ignored if NULL.
*
* @return ::NC_NOERR No error.
* @return ::NC_ENOTVAR Variable not found.
* @author Ed Hartnett
*/
int
nc4_hdf5_find_grp_h5_var(int ncid, int varid, NC_FILE_INFO_T **h5,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var)
{
NC_FILE_INFO_T *my_h5;
NC_GRP_INFO_T *my_grp;
NC_VAR_INFO_T *my_var;
int retval;
/* Look up file and group metadata. */
if ((retval = nc4_find_grp_h5(ncid, &my_grp, &my_h5)))
return retval;
assert(my_grp && my_h5);
/* Find the var. */
if (!(my_var = (NC_VAR_INFO_T *)ncindexith(my_grp->vars, varid)))
return NC_ENOTVAR;
assert(my_var && my_var->hdr.id == varid);
/* Do we need to read var metadata? */
if (!my_var->meta_read && my_var->created)
if ((retval = nc4_get_var_meta(my_var)))
return retval;
/* Return pointers that caller wants. */
if (h5)
*h5 = my_h5;
if (grp)
*grp = my_grp;
if (var)
*var = my_var;
return NC_NOERR;
}
/**
* @internal Given an ncid, varid, and attribute name, return
* normalized name and pointers to the file, group, var, and att info
* structs. Lazy reads of attributes and variable metadata are done as
* needed.
*
* @param ncid File/group ID.
* @param varid Variable ID.
@ -801,6 +854,11 @@ nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum,
if ((retval = nc4_read_atts(my_grp, my_var)))
return retval;
/* Do we need to read var metadata? */
if (!my_var->meta_read && my_var->created)
if ((retval = nc4_get_var_meta(my_var)))
return retval;
attlist = my_var->att;
}
assert(attlist);

View File

@ -99,8 +99,7 @@ typedef struct {
* @author Ed Hartnett
*/
static int
get_type_info2(NC_FILE_INFO_T *h5, hid_t datasetid,
NC_TYPE_INFO_T **type_info)
get_type_info2(NC_FILE_INFO_T *h5, hid_t datasetid, NC_TYPE_INFO_T **type_info)
{
NC_HDF5_TYPE_INFO_T *hdf5_type;
htri_t is_str, equal = 0;
@ -191,17 +190,17 @@ get_type_info2(NC_FILE_INFO_T *h5, hid_t datasetid,
/* Find out about endianness. As of HDF 1.8.6, this works
* with all data types Not just H5T_INTEGER. See
* https://www.hdfgroup.org/HDF5/doc/RM/RM_H5T.html#Datatype-GetOrder */
if((order = H5Tget_order(hdf_typeid)) < 0)
if ((order = H5Tget_order(hdf_typeid)) < 0)
return NC_EHDFERR;
if(order == H5T_ORDER_LE)
if (order == H5T_ORDER_LE)
(*type_info)->endianness = NC_ENDIAN_LITTLE;
else if(order == H5T_ORDER_BE)
else if (order == H5T_ORDER_BE)
(*type_info)->endianness = NC_ENDIAN_BIG;
else
return NC_EBADTYPE;
if(class == H5T_INTEGER)
if (class == H5T_INTEGER)
(*type_info)->nc_type_class = NC_INT;
else
(*type_info)->nc_type_class = NC_FLOAT;
@ -262,6 +261,11 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
int retval = NC_NOERR;
assert(grp && var && var->format_var_info);
LOG((3, "%s: var->hdr.name %s", __func__, var->hdr.name));
/* Have we already read the coordinates hidden att for this var? */
if (var->coords_read)
return NC_NOERR;
/* Get HDF5-sepecific var info. */
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
@ -295,12 +299,16 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
/* Read the dimids for this var. */
if (H5Aread(coord_attid, coord_att_typeid, var->dimids) < 0)
BAIL(NC_EATTMETA);
LOG((4, "read dimids for this var"));
/* Update var->dim field based on the var->dimids. Ok if does not
* find a dim at this time, but if found set it. */
for (d = 0; d < var->ndims; d++)
nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
/* Remember that we have read the coordinates hidden attribute. */
var->coords_read = NC_TRUE;
exit:
if (spaceid >= 0 && H5Sclose(spaceid) < 0)
BAIL2(NC_EHDFERR);
@ -493,6 +501,15 @@ rec_match_dimscales(NC_GRP_INFO_T *grp)
nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
}
/* Skip dimension scale variables */
if (var->dimscale)
continue;
/* If we have already read hidden coordinates att, then we don't
* have to match dimscales for this var. */
if (var->coords_read)
continue;
/* Skip dimension scale variables */
if (!var->dimscale)
{
@ -543,8 +560,6 @@ rec_match_dimscales(NC_GRP_INFO_T *grp)
}
} /* next dim */
} /* next grp */
LOG((5, "%s: dimid for this dimscale is %d", __func__,
var->type_info->hdr.id));
} /* next var->dim */
}
else
@ -1033,7 +1048,61 @@ static int get_chunking_info(hid_t propid, NC_VAR_INFO_T *var)
}
/**
* @internal This function reads scale info for vars, whether there
* @internal This function gets info about the dimscales attached to a
* dataset. The info is used later for dimscale matching.
*
* @param var Pointer to var info struct.
* @param hdf5_var Pointer to HDF5 var info struct.
* @param ndims Number of dims for this var.
* @param datasetid HDF5 datasetid.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOMEM Out of memory.
* @return ::NC_EHDFERR HDF5 returned error.
* @return ::NC_EVARMETA Error with var metadata.
* @author Ed Hartnett, Dennis Heimbigner
*/
static int
get_attached_info(NC_VAR_INFO_T *var, NC_HDF5_VAR_INFO_T *hdf5_var, int ndims,
hid_t datasetid)
{
int d;
int num_scales = 0;
/* Find out how many scales are attached to this
* dataset. H5DSget_num_scales returns an error if there are no
* scales, so convert a negative return value to zero. */
num_scales = H5DSget_num_scales(datasetid, 0);
if (num_scales < 0)
num_scales = 0;
if (num_scales && ndims)
{
/* Allocate space to remember whether the dimscale has been
* attached for each dimension. */
if (!(var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
return NC_ENOMEM;
/* Store id information allowing us to match hdf5
* dimscales to netcdf dimensions. */
if (!(hdf5_var->dimscale_hdf5_objids = malloc(ndims *
sizeof(struct hdf5_objid))))
return NC_ENOMEM;
for (d = 0; d < var->ndims; d++)
{
if (H5DSiterate_scales(hdf5_var->hdf_datasetid, d, NULL, dimscale_visitor,
&(hdf5_var->dimscale_hdf5_objids[d])) < 0)
return NC_EHDFERR;
var->dimscale_attached[d] = NC_TRUE;
}
}
return NC_NOERR;
}
/**
* @internal This function reads scale info for vars, whether they
* are scales or not.
*
* @param grp Pointer to group info struct.
@ -1055,7 +1124,6 @@ static int
get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
NC_HDF5_VAR_INFO_T *hdf5_var, int ndims, hid_t datasetid)
{
int d;
int retval;
/* If it's a scale, mark it as such. */
@ -1078,35 +1146,9 @@ get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
}
else /* Not a scale. */
{
int num_scales = 0;
/* Find out how many scales are attached to this
* dataset. H5DSget_num_scales returns an error if there are no
* scales, so convert a negative return value to zero. */
num_scales = H5DSget_num_scales(datasetid, 0);
if (num_scales < 0)
num_scales = 0;
if (num_scales && ndims)
{
/* Allocate space to remember whether the dimscale has been
* attached for each dimension. */
if (!(var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
return NC_ENOMEM;
/* Store id information allowing us to match hdf5
* dimscales to netcdf dimensions. */
if (!(hdf5_var->dimscale_hdf5_objids = malloc(ndims *
sizeof(struct hdf5_objid))))
return NC_ENOMEM;
for (d = 0; d < var->ndims; d++)
{
if (H5DSiterate_scales(hdf5_var->hdf_datasetid, d, NULL, dimscale_visitor,
&(hdf5_var->dimscale_hdf5_objids[d])) < 0)
return NC_EHDFERR;
var->dimscale_attached[d] = NC_TRUE;
}
}
if (!var->coords_read)
if ((retval = get_attached_info(var, hdf5_var, ndims, datasetid)))
return retval;
}
return NC_NOERR;
@ -1124,8 +1166,8 @@ get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
* @return ::NC_EVARMETA Error with var metadata.
* @author Ed Hartnett
*/
static int
get_var_meta(NC_VAR_INFO_T *var)
int
nc4_get_var_meta(NC_VAR_INFO_T *var)
{
NC_HDF5_VAR_INFO_T *hdf5_var;
hid_t access_pid = 0;
@ -1134,6 +1176,11 @@ get_var_meta(NC_VAR_INFO_T *var)
int retval = NC_NOERR;
assert(var && var->format_var_info);
LOG((3, "%s: var %s", var->hdr.name));
/* Have we already read the var metadata? */
if (var->meta_read)
return NC_NOERR;
/* Get pointer to the HDF5-specific var info struct. */
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
@ -1160,14 +1207,6 @@ get_var_meta(NC_VAR_INFO_T *var)
if ((retval = get_filter_info(propid, var)))
BAIL(retval);
/* Learn all about the type of this variable. */
if ((retval = get_type_info2(var->container->nc4_info, hdf5_var->hdf_datasetid,
&var->type_info)))
BAIL(retval);
/* Indicate that the variable has a pointer to the type */
var->type_info->rc++;
/* Get fill value, if defined. */
if ((retval = get_fill_info(propid, var)))
BAIL(retval);
@ -1177,6 +1216,13 @@ get_var_meta(NC_VAR_INFO_T *var)
if ((retval = nc4_adjust_var_cache(var->container, var)))
BAIL(retval);
if (var->coords_read && !var->dimscale)
if ((retval = get_attached_info(var, hdf5_var, var->ndims, hdf5_var->hdf_datasetid)))
return retval;
/* Remember that we have read the metadata for this var. */
var->meta_read = NC_TRUE;
exit:
if (access_pid && H5Pclose(access_pid) < 0)
BAIL2(NC_EHDFERR);
@ -1255,25 +1301,33 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name,
retval = read_coord_dimids(grp, var);
if (retval && retval != NC_ENOTATT)
BAIL(retval);
retval = NC_NOERR;
/* Handle scale info. */
if ((retval = get_scale_info(grp, dim, var, hdf5_var, ndims, datasetid)))
BAIL(retval);
/* Get the rest of the metadata for this variable. */
if ((retval = get_var_meta(var)))
/* Learn all about the type of this variable. This will fail for
* HDF5 reference types, and then the var we just created will be
* deleted, thus ignoring HDF5 reference type objects. */
if ((retval = get_type_info2(var->container->nc4_info, hdf5_var->hdf_datasetid,
&var->type_info)))
BAIL(retval);
/* Indicate that the variable has a pointer to the type */
var->type_info->rc++;
exit:
if (finalname)
free(finalname);
if (retval)
{
/* If there was an error, decrement the dataset ref counter, and
* delete the var info struct we just created. */
if (incr_id_rc && H5Idec_ref(datasetid) < 0)
BAIL2(NC_EHDFERR);
if (var != NULL) {
nc4_var_list_del(grp,var);
}
if (var)
nc4_var_list_del(grp, var);
}
return retval;
@ -2385,12 +2439,12 @@ exit:
/**
* @internal This is the main function to recursively read all the
* metadata for the file. The links in the 'grp' are iterated over
* and added to the file's metadata information. Note that child
* groups are not immediately processed, but are deferred until all
* the other links in the group are handled (so that vars in the child
* groups are guaranteed to have types that they use in a parent group
* in place).
* metadata for the file. The links in the 'grp' are iterated over and
* added to the file's metadata information. Note that child groups
* are not immediately processed, but are deferred until all the other
* links in the group are handled (so that vars in the child groups
* are guaranteed to have types that they use in a parent group in
* place).
*
* @param grp Pointer to a group.
*
@ -2404,13 +2458,13 @@ static int
rec_read_metadata(NC_GRP_INFO_T *grp)
{
NC_HDF5_GRP_INFO_T *hdf5_grp;
user_data_t udata; /* User data for iteration */
user_data_t udata; /* User data for iteration */
hdf5_obj_info_t *oinfo; /* Pointer to info for object */
hsize_t idx = 0;
hid_t pid = -1;
unsigned crt_order_flags = 0;
H5_index_t iter_index;
int i, retval = NC_NOERR; /* everything worked! */
int i, retval = NC_NOERR;
assert(grp && grp->hdr.name && grp->format_grp_info);
LOG((3, "%s: grp->hdr.name %s", __func__, grp->hdr.name));
@ -2424,6 +2478,7 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
{
if (grp->parent)
{
/* This is a child group. */
NC_HDF5_GRP_INFO_T *parent_hdf5_grp;
parent_hdf5_grp = (NC_HDF5_GRP_INFO_T *)grp->parent->format_grp_info;
@ -2433,6 +2488,7 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
}
else
{
/* This is the root group. */
NC_HDF5_FILE_INFO_T *hdf5_info;
hdf5_info = (NC_HDF5_FILE_INFO_T *)grp->nc4_info->format_file_info;
@ -2443,13 +2499,13 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
}
assert(hdf5_grp->hdf_grpid > 0);
/* Get the group creation flags, to check for creation ordering */
/* Get the group creation flags, to check for creation ordering. */
if ((pid = H5Gget_create_plist(hdf5_grp->hdf_grpid)) < 0)
BAIL(NC_EHDFERR);
if (H5Pget_link_creation_order(pid, &crt_order_flags) < 0)
BAIL(NC_EHDFERR);
/* Set the iteration index to use */
/* Set the iteration index to use. */
if (crt_order_flags & H5P_CRT_ORDER_TRACKED)
iter_index = H5_INDEX_CRT_ORDER;
else
@ -2463,27 +2519,28 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
iter_index = H5_INDEX_NAME;
}
/* Set user data for iteration. */
/* Set user data for iteration over any child groups. */
udata.grp = grp;
udata.grps = nclistnew();
/* Iterate over links in this group, building lists for the types,
* datasets and groups encountered. A pointer to udata will be
* passed as a parameter to the callback function
* read_hdf5_obj(). */
* read_hdf5_obj(). (I have also tried H5Oiterate(), but it is much
* slower iterating over the same file - Ed.) */
if (H5Literate(hdf5_grp->hdf_grpid, iter_index, H5_ITER_INC, &idx,
read_hdf5_obj, (void *)&udata) < 0)
BAIL(NC_EHDFERR);
/* Process the child groups found. (Deferred until now, so that the
* types in the current group get processed and are available for
* vars in the child group(s).) */
* types in the current group get processed and are available for
* vars in the child group(s).) */
for (i = 0; i < nclistlength(udata.grps); i++)
{
NC_GRP_INFO_T *child_grp;
oinfo = (hdf5_obj_info_t*)nclistget(udata.grps, i);
/* Add group to file's hierarchy */
/* Add group to file's hierarchy. */
if ((retval = nc4_grp_list_add(grp->nc4_info, grp, oinfo->oname,
&child_grp)))
BAIL(retval);
@ -2495,16 +2552,12 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
/* Recursively read the child group's metadata. */
if ((retval = rec_read_metadata(child_grp)))
BAIL(retval);
/* Close the object. */
if (H5Oclose(oinfo->oid) < 0)
BAIL(NC_EHDFERR);
}
/* Defer the reading of global atts until someone asks for one. */
grp->atts_not_read = 1;
/* When exiting define mode, mark all variable written. */
/* When reading existing file, mark all variables as written. */
for (i = 0; i < ncindexsize(grp->vars); i++)
((NC_VAR_INFO_T *)ncindexith(grp->vars, i))->written_to = NC_TRUE;
@ -2512,16 +2565,13 @@ exit:
if (pid > 0 && H5Pclose(pid) < 0)
BAIL2(NC_EHDFERR);
/* Clean up local information, if anything remains. */
/* Clean up list of child groups. */
for (i = 0; i < nclistlength(udata.grps); i++)
{
oinfo = (hdf5_obj_info_t *)nclistget(udata.grps, i);
if (retval)
{
/* Close the object */
if (H5Oclose(oinfo->oid) < 0)
BAIL2(NC_EHDFERR);
}
/* Close the open HDF5 object. */
if (H5Oclose(oinfo->oid) < 0)
BAIL2(NC_EHDFERR);
free(oinfo);
}
nclistfree(udata.grps);

View File

@ -409,6 +409,7 @@ NC4_def_var(int ncid, const char *name, nc_type xtype,
BAIL(NC_ENOMEM);
var->is_new_var = NC_TRUE;
var->meta_read = NC_TRUE;
/* Point to the type, and increment its ref. count */
var->type_info = type;
@ -852,7 +853,7 @@ nc_def_var_chunking_ints(int ncid, int varid, int contiguous, int *chunksizesp)
int i, retval;
/* Get pointer to the var. */
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
if ((retval = nc4_hdf5_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
return retval;
assert(var);
@ -1088,6 +1089,11 @@ NC4_rename_var(int ncid, int varid, const char *name)
there. */
if (var->created)
{
/* Do we need to read var metadata? */
if (!var->meta_read)
if ((retval = nc4_get_var_meta(var)))
return retval;
if (var->ndims)
{
NC_HDF5_DIM_INFO_T *hdf5_d0;
@ -1353,7 +1359,7 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
size_t len = 1;
/* Find info for this file, group, and var. */
if ((retval = nc4_find_grp_h5_var(ncid, varid, &h5, &grp, &var)))
if ((retval = nc4_hdf5_find_grp_h5_var(ncid, varid, &h5, &grp, &var)))
return retval;
assert(h5 && grp && var && var->hdr.id == varid && var->format_var_info);
@ -1679,7 +1685,7 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
size_t len = 1;
/* Find info for this file, group, and var. */
if ((retval = nc4_find_grp_h5_var(ncid, varid, &h5, &grp, &var)))
if ((retval = nc4_hdf5_find_grp_h5_var(ncid, varid, &h5, &grp, &var)))
return retval;
assert(h5 && grp && var && var->hdr.id == varid && var->format_var_info &&
var->type_info && var->type_info->size && var->type_info->format_type_info);

View File

@ -1009,6 +1009,13 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
var->created = NC_TRUE;
var->is_new_var = NC_FALSE;
/* Always write the hidden coordinates attribute, which lists the
* dimids of this var. When present, this speeds opens. When no
* present, dimscale matching is used. */
if (var->ndims > 1)
if ((retval = write_coord_dimids(var)))
BAIL(retval);
/* If this is a dimscale, mark it as such in the HDF5 file. Also
* find the dimension info and store the dataset id of the dimscale
* dataset. */
@ -1019,9 +1026,9 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
/* If this is a multidimensional coordinate variable, write a
* coordinates attribute. */
if (var->ndims > 1)
if ((retval = write_coord_dimids(var)))
BAIL(retval);
/* if (var->ndims > 1) */
/* if ((retval = write_coord_dimids(var))) */
/* BAIL(retval); */
/* If desired, write the netCDF dimid. */
if (write_dimid)

View File

@ -845,10 +845,12 @@ NC3_put_att(
#if 0
if (varid != NC_GLOBAL && !strcmp(name, _FillValue)) {
/* Fill value must be of the same data type*/
/* Fill value must be of the same data type */
if (type != ncp->vars.value[varid]->type) return NC_EBADTYPE;
/* Fill value must have exactly one value */
if (nelems != 1) return NC_EINVAL;
/* Only allow for variables defined in initial define mode */
if (ncp->old != NULL && varid < ncp->old->vars.nelems)
return NC_ELATEFILL; /* try put attribute for an old variable */

View File

@ -275,6 +275,7 @@ nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim,
NC_GRP_INFO_T **dim_grp)
{
assert(grp && grp->nc4_info && dim);
LOG((4, "%s: dimid %d", __func__, dimid));
/* Find the dim info. */
if (!((*dim) = nclistget(grp->nc4_info->alldims, dimid)))

View File

@ -4,6 +4,8 @@
# This file builds and runs the nc_test program, which tests the
# netCDF-3 API for all formats.
# Ed Hartnett, Dennis Heimbigner, Ward Fisher
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
AM_CPPFLAGS += -I$(top_srcdir)/libsrc
@ -12,19 +14,20 @@ AM_CPPFLAGS += -DTOPBINDIR=${abs_top_bindir}
LDADD = ${top_builddir}/liblib/libnetcdf.la
AM_CPPFLAGS += -I$(top_builddir)/liblib -I$(top_builddir)/include -I$(top_srcdir)/libsrc
# Note which tests depend on other tests. necessary for make -j check
TEST_EXTENSIONS = .sh
check_PROGRAMS =
# These are the tests which are always run.
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm tst_names \
tst_nofill tst_nofill2 tst_nofill3 tst_atts3 tst_meta tst_inq_type \
tst_utf8_validate tst_utf8_phrases tst_global_fillval \
tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef \
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm tst_names \
tst_nofill tst_nofill2 tst_nofill3 tst_atts3 tst_meta tst_inq_type \
tst_utf8_validate tst_utf8_phrases tst_global_fillval \
tst_max_var_dims tst_formats tst_def_var_fill tst_err_enddef \
tst_default_format
if USE_PNETCDF
TESTPROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar tst_formatx_pnetcdf \
tst_default_format_pnetcdf
check_PROGRAMS += tst_parallel2 tst_pnetcdf tst_addvar
TESTPROGRAMS += tst_formatx_pnetcdf tst_default_format_pnetcdf
endif
if TEST_PARALLEL4
@ -48,16 +51,14 @@ endif # LARGE_FILE_TESTS
if BUILD_BENCHMARKS
TESTPROGRAMS += testnc3perf
testnc3perf_SOURCES = testnc3perf.c
endif
if USE_HDF5
TESTPROGRAMS += tst_diskless6
tst_diskless6_SOURCES = tst_diskless6.c
endif
# Set up the tests.
check_PROGRAMS = $(TESTPROGRAMS)
check_PROGRAMS += $(TESTPROGRAMS)
# Build Diskless test helpers
check_PROGRAMS += tst_diskless tst_diskless3 tst_diskless4 \

View File

@ -20,6 +20,7 @@
* netCDF I/O.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

View File

@ -26,6 +26,7 @@ See \ref copyright file for more info.
* Check the first new variable's begin to see whether it is less than
* the last variable's offset in the existing file.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -7,12 +7,12 @@
* Author: Wei-keng Liao.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netcdf.h>
#define CHECK_ERR { \
if (err != NC_NOERR) { \
nerrs++; \

View File

@ -98,7 +98,7 @@ create_check_pnetcdf(char *fname, int cmode, int exp_format)
int main(int argc, char *argv[])
{
char *fname="tst_default_format.nc";
char *fname="tst_default_format_pnetcdf.nc";
int err, exp_err=NC_NOERR, nerrs=0, ncid, cmode;
MPI_Init(&argc, &argv);

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <netcdf.h>

View File

@ -224,6 +224,81 @@ main(int argc, char **argv)
SUMMARIZE_ERR;
} /* next fill value method test */
} /* next fill val write test */
#define NDIM2 2
#define DIM1_NAME "dim1"
#define DIM2_NAME "dim2"
#define NTYPE 6
#define DATA_LEN 4
printf("*** testing handling of null strides with format %d... ",
format[f]);
{
char file_name[NC_MAX_NAME + 1];
char var_name[NC_MAX_NAME + 1];
int dimid[NDIM2];
int xtype[NTYPE] = {NC_BYTE, NC_CHAR, NC_SHORT, NC_INT, NC_FLOAT, NC_DOUBLE};
int type_size[NTYPE] = {1, 1, 2, 4, 4, 8};
int varid[NTYPE];
size_t start[NDIM2] = {0, 0};
size_t count[NDIM2] = {2, 2};
signed char data_byte[DATA_LEN] = {1, 2, 3, 4};
unsigned char data_char[DATA_LEN] = {1, 2, 3, 4};
short data_short[DATA_LEN] = {1, 2, 3, 4};
int data_int[DATA_LEN] = {1, 2, 3, 4};
float data_float[DATA_LEN] = {1, 2, 3, 4};
double data_double[DATA_LEN] = {1, 2, 3, 4};
void *data_ptr[NTYPE] = {data_byte, data_char, data_short, data_int, data_float, data_double};
int t;
/* Create the test file. */
sprintf(file_name, "%s_%d_null_strides.nc", FILE_NAME_BASE, format[f]);
if (nc_set_default_format(format[f], NULL)) ERR;
if (nc_create(file_name, 0, &ncid)) ERR;
if (nc_def_dim(ncid, DIM1_NAME, DIM_LEN, &dimid[0])) ERR;
if (nc_def_dim(ncid, DIM2_NAME, DIM_LEN, &dimid[1])) ERR;
for (t = 0; t < NTYPE; t++)
{
sprintf(var_name, "var_%d", xtype[t]);
if (nc_def_var(ncid, var_name, xtype[t], NDIM2, dimid, &varid[t])) ERR;
}
if (nc_enddef(ncid)) ERR;
/* Write some data. */
for (t = 0; t < NTYPE; t++)
{
if (nc_put_vars(ncid, varid[t], start, count, NULL, data_ptr[t])) ERR;
}
if (nc_close(ncid)) ERR;
/* Open the file and check data. */
{
int ndims, nvars, ngatts, unlimdimid;
if (nc_open(file_name, NC_NOWRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (ndims != 2 || nvars != NTYPE || ngatts != 0 || unlimdimid != -1) ERR;
for (t = 0; t < NTYPE; t++)
{
nc_type my_type;
int var_ndims, natts;
int var_dimid[NDIM2];
void *data_in;
if (nc_inq_var(ncid, varid[t], NULL, &my_type, &var_ndims, var_dimid, &natts)) ERR;
if (my_type != xtype[t] || var_ndims != 2 || var_dimid[0] != dimid[0] ||
var_dimid[1] != dimid[1] || natts != 0) ERR;
if (!(data_in = malloc(DATA_LEN * type_size[t]))) ERR;
if (nc_get_vars(ncid, varid[t], start, count, NULL, data_in)) ERR;
if (memcmp(data_in, data_ptr[t], DATA_LEN * type_size[t])) ERR;
free(data_in);
}
if (nc_close(ncid)) ERR;
}
}
SUMMARIZE_ERR;
} /* next format */
}
FINAL_RESULTS;

View File

@ -371,7 +371,6 @@ modify_file_extra(int ncid)
size_t i;
int varidx;
int dimid[1];
size_t len;
int data[MAXDIMLEN];
/* open file for new meta-data */

View File

@ -8,10 +8,10 @@
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <netcdf.h>

View File

@ -9,6 +9,7 @@ See \ref copyright file for more info.
*/
#include <config.h>
#include <stdio.h>
#include <netcdf.h>

View File

@ -9,6 +9,7 @@
*/
#include <config.h>
#include <stdio.h> /* printf() */
#include <config.h>
#include <stdlib.h>

View File

@ -140,6 +140,7 @@ int main(int argc, char* argv[])
}
}
st = nc_close(ncid); CHK_ERR(st)
free(buf);
fn_exit:
MPI_Finalize();

View File

@ -4,6 +4,7 @@
* $Id: util.c 2792 2014-10-27 06:02:59Z wkliao $
*********************************************************************/
#include <config.h>
#include <math.h> /* floor() */
#include "tests.h"

View File

@ -13,17 +13,15 @@ include $(top_srcdir)/lib_flags.am
# Un comment to use a more verbose test driver
#SH_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
#LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver-verbose
TEST_EXTENSIONS = .sh
# Note which tests depend on other tests. necessary for make -j check
extradir =
TEST_EXTENSIONS = .sh
# Link to our assembled library.
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
LDADD = ${top_builddir}/liblib/libnetcdf.la
# These are netCDF-4 C test programs which are built and run.
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
NC4_TESTS = tst_dims tst_dims2 tst_dims3 tst_files tst_files4 \
tst_vars tst_varms tst_unlim_vars tst_converts tst_converts2 tst_grps \
tst_grps2 tst_compounds tst_compounds2 tst_compounds3 tst_opaques \
tst_strings tst_strings2 tst_interops tst_interops4 tst_interops5 \
@ -41,14 +39,9 @@ if !ISCYGWIN
NC4_TESTS += tst_h_strbug tst_h_refs
endif
check_PROGRAMS =
TESTS =
# Build test programs plus programs used in test scripts.
if USE_NETCDF4
check_PROGRAMS += $(NC4_TESTS) renamegroup tst_empty_vlen_unlim
TESTS += $(NC4_TESTS)
endif
check_PROGRAMS = $(NC4_TESTS) tst_empty_vlen_unlim
TESTS = $(NC4_TESTS) run_empty_vlen_test.sh
# Add these if large file tests are turned on.
if LARGE_FILE_TESTS
@ -56,14 +49,11 @@ check_PROGRAMS += tst_large tst_large2
TESTS += tst_large tst_large2
endif
if USE_NETCDF4
if BUILD_UTILITIES
check_PROGRAMS += renamegroup
TESTS += run_grp_rename.sh tst_misc.sh
endif
TESTS += run_empty_vlen_test.sh
endif
# If the v2 API was built, add its test program.
if BUILD_V2
check_PROGRAMS += tst_v2
@ -117,6 +107,7 @@ endif
# Filter Tests (requires ncdump and ncgen)
if ENABLE_FILTER_TESTING
if BUILD_UTILITIES
extradir =
extra_PROGRAMS = test_filter test_filter_misc
TESTS += tst_filter.sh
endif

View File

@ -12,6 +12,7 @@ See \ref copyright file for more info.
Open a netcdf-4 file with horrendously large metadata.
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

View File

@ -1210,7 +1210,7 @@ create_file()
check_err(stat,__LINE__,__FILE__);
}
{ /* Gi */
static const int Gi_att[4] = {-2147483648, 2147483647, -2147483648, -2147483648} ;
static const int Gi_att[] = {-2147483647-1,2147483647,-2147483647-1,-2147483647-1};
stat = nc_put_att_int(ncid, NC_GLOBAL, "Gi", NC_INT, 4, Gi_att);
check_err(stat,__LINE__,__FILE__);
}
@ -1242,7 +1242,7 @@ create_file()
check_err(stat,__LINE__,__FILE__);
}
{ /* i */
static const int i_i_att[3] = {-2147483648, 2147483647, -2147483648} ;
static const int i_i_att[3] = {-2147483647-1, 2147483647, -2147483647-1} ;
stat = nc_put_att_int(ncid, i_id, "i", NC_INT, 3, i_i_att);
check_err(stat,__LINE__,__FILE__);
}
@ -1322,7 +1322,7 @@ create_file()
}
{
int ir_data[2] = {-2147483648, 2147483647} ;
int ir_data[2] = {-2147483647-1, 2147483647} ;
size_t ir_startset[1] = {0} ;
size_t ir_countset[1] = {2} ;
stat = nc_put_vara(ncid, ir_id, ir_startset, ir_countset, ir_data);
@ -1370,7 +1370,7 @@ create_file()
}
{
int i1_data[1] = {-2147483648} ;
int i1_data[1] = {(-2147483647)-1} ;
size_t i1_startset[1] = {0} ;
size_t i1_countset[1] = {1} ;
stat = nc_put_vara(ncid, i1_id, i1_startset, i1_countset, i1_data);
@ -1418,7 +1418,7 @@ create_file()
}
{
int i2_data[2] = {-2147483648, 2147483647} ;
int i2_data[2] = {(-2147483647)-1, 2147483647} ;
size_t i2_startset[1] = {0} ;
size_t i2_countset[1] = {2} ;
stat = nc_put_vara(ncid, i2_id, i2_startset, i2_countset, i2_data);
@ -1466,7 +1466,7 @@ create_file()
}
{
int i3_data[3] = {-2147483648, 2147483647, -2147483648} ;
int i3_data[3] = {(-2147483647)-1, 2147483647, (-2147483647)-1} ;
size_t i3_startset[1] = {0} ;
size_t i3_countset[1] = {3} ;
stat = nc_put_vara(ncid, i3_id, i3_startset, i3_countset, i3_data);
@ -1514,7 +1514,7 @@ create_file()
}
{
int i4_data[4] = {-2147483648, 2147483647, -2147483648, -2147483648} ;
int i4_data[4] = {(-2147483647)-1, 2147483647, (-2147483647)-1, (-2147483647)-1} ;
size_t i4_startset[1] = {0} ;
size_t i4_countset[1] = {4} ;
stat = nc_put_vara(ncid, i4_id, i4_startset, i4_countset, i4_data);

View File

@ -11,8 +11,8 @@
$Id$
*/
#include <netcdf.h>
#include <config.h>
#include <netcdf.h>
#include <nc_tests.h>
#include "err_macros.h"
#include <string.h>

View File

@ -28,6 +28,7 @@
#define NUM_ATTS 100
#define ATT_LEN 100
#define NUM_VARS 1
#define NUM_VARS_MANY 5000
int
add_attributes(int ncid, int varid, size_t num_atts, size_t att_len)
@ -59,8 +60,7 @@ add_attributes(int ncid, int varid, size_t num_atts, size_t att_len)
/* Build the test file. */
int
buildfile(size_t num_vars, size_t num_atts, size_t att_len,
char *file_name)
buildfile(size_t num_vars, size_t num_atts, size_t att_len, char *file_name)
{
int ncid, varid;
int dimids[NDIMS];
@ -102,10 +102,13 @@ readfile(char *file_name, long long *delta, int do_inq, int num_vars)
if (nc_open(file_name, NC_NETCDF4, &ncid)) ERR;
/* Do an inq if desired, triggering read of atts. */
for (v = 0; v < num_vars; v++)
if (nc_inq_varnatts(ncid, v, &natts)) ERR;
if (do_inq)
{
for (v = 0; v < num_vars; v++)
if (nc_inq_varnatts(ncid, v, &natts)) ERR;
if (nc_inq_natts(ncid, &natts)) ERR;
if (nc_inq_natts(ncid, &natts)) ERR;
}
/* Close the file. */
if (nc_close(ncid)) ERR;
@ -166,9 +169,10 @@ readfile_hdf5(char *file_name, long long *delta, int do_inq, int num_vars)
return 0;
}
#define NUM_RUNS 5
#define NUM_STEPS 20
#define NUM_RUNS 1
#define NUM_STEPS 10
#define FACTOR 100
#define VAR_FACTOR 500
#define NUM_INQ_TESTS 2
int
main(int argc, char **argv)
@ -179,31 +183,24 @@ main(int argc, char **argv)
int factor;
int r, s, num_vars, do_inq;
for (do_inq = 0; do_inq < NUM_INQ_TESTS; do_inq++)
printf("Testing with many vars...\n");
{
for (num_vars = 0; num_vars <= NUM_VARS; num_vars++)
for (do_inq = 0; do_inq < 1; do_inq++)
{
/* Reset. */
num_atts = 1;
factor = FACTOR;
printf("*** %s %s\n", num_vars ? "variable attributes" : "global attributes",
do_inq ? "with inq" : "");
printf("Number of Attributes\tHDF5 Open Time (s)\tNetcdf4 Open Time (s)\n");
for (s = 0; s < NUM_STEPS; s++)
printf("Number of Variables\tHDF5 Open Time (s)\tNetcdf4 Open Time (s)\n");
for (num_vars = 1; num_vars <= NUM_VARS_MANY; num_vars += VAR_FACTOR)
{
num_atts = 10;
tot_nc4 = 0;
tot_hdf5 = 0;
num_atts += factor * s;
for (r = 0; r < NUM_RUNS; r++)
{
long long nc4_open_time;
long long hdf5_open_time;
long long nc4_open_time = 0;
long long hdf5_open_time = 0;
/* Determine file name. */
sprintf(file_name, "%s_%d_%d_%d.nc", TEST, num_vars, s, r);
sprintf(file_name, "%s_%d_%d.nc", TEST, num_vars, r);
if (buildfile(num_vars, num_atts, ATT_LEN, file_name)) ERR;
if (readfile(file_name, &nc4_open_time, do_inq, num_vars)) ERR;
@ -213,11 +210,54 @@ main(int argc, char **argv)
}
/* Print average results to the millisec */
printf("%ld\t%g\t%g\n", num_atts, tot_hdf5/((float)NUM_RUNS * 1000000),
printf("%d\t%g\t%g\n", num_vars, tot_hdf5/((float)NUM_RUNS * 1000000),
tot_nc4/((float)NUM_RUNS * 1000000));
}
}
} /* next do_inq */
} /* next do_inq */
}
SUMMARIZE_ERR;
printf("Testing with many atts...\n");
{
for (do_inq = 0; do_inq < NUM_INQ_TESTS; do_inq++)
{
for (num_vars = 0; num_vars <= NUM_VARS; num_vars++)
{
/* Reset. */
num_atts = 1;
factor = FACTOR;
printf("*** %s %s\n", num_vars ? "variable attributes" : "global attributes",
do_inq ? "with inq" : "");
printf("Number of Attributes\tHDF5 Open Time (s)\tNetcdf4 Open Time (s)\n");
for (s = 0; s < NUM_STEPS; s++)
{
tot_nc4 = 0;
tot_hdf5 = 0;
num_atts += factor * s;
for (r = 0; r < NUM_RUNS; r++)
{
long long nc4_open_time;
long long hdf5_open_time;
/* Determine file name. */
sprintf(file_name, "%s_%d_%d_%d.nc", TEST, num_vars, s, r);
if (buildfile(num_vars, num_atts, ATT_LEN, file_name)) ERR;
if (readfile(file_name, &nc4_open_time, do_inq, num_vars)) ERR;
if (readfile_hdf5(file_name, &hdf5_open_time, do_inq, num_vars)) ERR;
tot_nc4 += nc4_open_time;
tot_hdf5 += hdf5_open_time;
}
/* Print average results to the millisec */
printf("%ld\t%g\t%g\n", num_atts, tot_hdf5/((float)NUM_RUNS * 1000000),
tot_nc4/((float)NUM_RUNS * 1000000));
}
}
} /* next do_inq */
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}

View File

@ -33,7 +33,7 @@ variables:
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
$Id: tst_coords3.c,v 1.1 2010/03/30 19:42:24 ed Exp $
Ed Hartnett
*/
#include <nc_tests.h>
@ -206,7 +206,7 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing with CF example http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.4/ch05s02.html....\n");
printf("**** simple test with only metadata");
printf("**** simple test with only metadata... ");
{
int ncid, dimids[NDIMS], varids[NVARS], data_dimids[DATA_NDIMS];
int coord_dimids[COORD_NDIMS];

View File

@ -20,48 +20,48 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing netcdf-4 dimensions some more.\n");
printf("*** Checking non-coordinate variable with same name as dimension...");
{
#define CRAZY "crazy"
#define NUTS "nuts"
#define NUM_CRAZY 3
#define NUM_NUTS 5
int nuts_dimid, crazy_dimid, dimid_in;
int varid, ncid;
nc_type xtype_in, xtype = NC_CHAR;
int ndims_in, nvars_in, natts_in, unlimdimid_in;
char name_in[NC_MAX_NAME + 1];
/* printf("*** Checking non-coordinate variable with same name as dimension..."); */
/* { */
/* #define CRAZY "crazy" */
/* #define NUTS "nuts" */
/* #define NUM_CRAZY 3 */
/* #define NUM_NUTS 5 */
/* int nuts_dimid, crazy_dimid, dimid_in; */
/* int varid, ncid; */
/* nc_type xtype_in, xtype = NC_CHAR; */
/* int ndims_in, nvars_in, natts_in, unlimdimid_in; */
/* char name_in[NC_MAX_NAME + 1]; */
/* Create a file with 2 dims and one var. The var is named the
* same as one of the dimensions, but uses the other dimension,
* and thus is not a netCDF coordinate variable. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, CRAZY, NUM_CRAZY, &crazy_dimid)) ERR;
if (nc_def_dim(ncid, NUTS, NUM_NUTS, &nuts_dimid)) ERR;
if (nc_def_var(ncid, CRAZY, xtype, NDIMS1, &nuts_dimid, &varid)) ERR;
/* /\* Create a file with 2 dims and one var. The var is named the */
/* * same as one of the dimensions, but uses the other dimension, */
/* * and thus is not a netCDF coordinate variable. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; */
/* if (nc_def_dim(ncid, CRAZY, NUM_CRAZY, &crazy_dimid)) ERR; */
/* if (nc_def_dim(ncid, NUTS, NUM_NUTS, &nuts_dimid)) ERR; */
/* if (nc_def_var(ncid, CRAZY, xtype, NDIMS1, &nuts_dimid, &varid)) ERR; */
/* Check out the file. */
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR;
if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 ||
natts_in != 0 || dimid_in != nuts_dimid) ERR;
/* /\* Check out the file. *\/ */
/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; */
/* if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR; */
/* if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 || */
/* natts_in != 0 || dimid_in != nuts_dimid) ERR; */
if (nc_close(ncid)) ERR;
/* if (nc_close(ncid)) ERR; */
/* Reopen and check the file. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
/* /\* Reopen and check the file. *\/ */
/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR;
if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 ||
natts_in != 0 || dimid_in != nuts_dimid) ERR;
/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; */
/* if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR; */
/* if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 || */
/* natts_in != 0 || dimid_in != nuts_dimid) ERR; */
if (nc_close(ncid)) ERR;
/* if (nc_close(ncid)) ERR; */
}
SUMMARIZE_ERR;
/* } */
/* SUMMARIZE_ERR; */
printf("*** Checking 2D coordinate variable with user-provided code...");
{
/* This test is from user Dipl.-Ing. Christian Schlamkow,
@ -82,7 +82,7 @@ main(int argc, char **argv)
nc_type xtype_in;
char name_in[NC_MAX_NAME + 1];
int i;
nc_set_log_level(4);
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
/*create dimensions*/

View File

@ -50,8 +50,8 @@ int main() {
printf("\t* Creating File:\tnc_create()\n");
if (nc_create(FILE_NAME_UNLIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
/* Set fill mode */
#if 0
/* Set fill mode */
printf("\t* Setting fill mode:\tnc_set_fill()\n");
if(nc_set_fill(ncid,NC_FILL,NULL)) ERR;
#endif
@ -144,8 +144,8 @@ int main() {
printf("\t* Creating File:\tnc_create()\n");
if (nc_create(FILE_NAME_LIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
/* Set fill mode */
#if 0
/* Set fill mode */
printf("\t* Setting fill mode:\tnc_set_fill()\n");
if(nc_set_fill(ncid,NC_FILL,NULL)) ERR;
#endif

View File

@ -20,71 +20,71 @@ int
main(int argc, char **argv)
{ /* create tst_classic_fills.nc */
printf("\n*** Testing fill values.\n");
printf("*** testing very simple scalar string var...");
{
#define STRING_VAR_NAME "Petition_of_Right"
#define NDIMS_STRING 1
/* printf("*** testing very simple scalar string var..."); */
/* { */
/* #define STRING_VAR_NAME "Petition_of_Right" */
/* #define NDIMS_STRING 1 */
int ncid, varid;
int varid_in;
const char *data_out[NDIMS_STRING] = {
"Humbly show unto our Sovereign Lord the King, the Lords "
"Spiritual and Temporal, and Commons in Parliament assembles, "
"that whereas it is declared and enacted by a statute made in "
"the time of the reign of King Edward I, commonly called "
"Stratutum de Tellagio non Concedendo, that no tallage or "
"aid shall be laid or levied by the king or his heirs in this "
"realm, without the good will and assent of the archbishops, "
"bishops, earls, barons, knights, burgesses, and other the "
"freemen of the commonalty of this realm; and by authority "
"of parliament holden in the five-and-twentieth year of the "
"reign of King Edward III, it is declared and enacted, that "
"from thenceforth no person should be compelled to make any "
"loans to the king against his will, because such loans were "
"against reason and the franchise of the land; and by other "
"laws of this realm it is provided, that none should be charged "
"by any charge or imposition called a benevolence, nor by such "
"like charge; by which statutes before mentioned, and other the "
"good laws and statutes of this realm, your subjects have inherited "
"this freedom, that they should not be compelled to contribute "
"to any tax, tallage, aid, or other like charge not set by "
"common consent, in parliament."
};
char *data_in[NDIMS_STRING];
size_t index1[NDIMS_STRING] = {0};
/* int ncid, varid; */
/* int varid_in; */
/* const char *data_out[NDIMS_STRING] = { */
/* "Humbly show unto our Sovereign Lord the King, the Lords " */
/* "Spiritual and Temporal, and Commons in Parliament assembles, " */
/* "that whereas it is declared and enacted by a statute made in " */
/* "the time of the reign of King Edward I, commonly called " */
/* "Stratutum de Tellagio non Concedendo, that no tallage or " */
/* "aid shall be laid or levied by the king or his heirs in this " */
/* "realm, without the good will and assent of the archbishops, " */
/* "bishops, earls, barons, knights, burgesses, and other the " */
/* "freemen of the commonalty of this realm; and by authority " */
/* "of parliament holden in the five-and-twentieth year of the " */
/* "reign of King Edward III, it is declared and enacted, that " */
/* "from thenceforth no person should be compelled to make any " */
/* "loans to the king against his will, because such loans were " */
/* "against reason and the franchise of the land; and by other " */
/* "laws of this realm it is provided, that none should be charged " */
/* "by any charge or imposition called a benevolence, nor by such " */
/* "like charge; by which statutes before mentioned, and other the " */
/* "good laws and statutes of this realm, your subjects have inherited " */
/* "this freedom, that they should not be compelled to contribute " */
/* "to any tax, tallage, aid, or other like charge not set by " */
/* "common consent, in parliament." */
/* }; */
/* char *data_in[NDIMS_STRING]; */
/* size_t index1[NDIMS_STRING] = {0}; */
/* Create file with a 1D string var. Set its fill value to the
* empty string. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_var(ncid, STRING_VAR_NAME, NC_STRING, 0, NULL, &varid)) ERR;
/* /\* Create file with a 1D string var. Set its fill value to the */
/* * empty string. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; */
/* if (nc_def_var(ncid, STRING_VAR_NAME, NC_STRING, 0, NULL, &varid)) ERR; */
/* Check it out. */
if (nc_inq_varid(ncid, STRING_VAR_NAME, &varid_in)) ERR;
if (varid_in != varid) ERR;
/* /\* Check it out. *\/ */
/* if (nc_inq_varid(ncid, STRING_VAR_NAME, &varid_in)) ERR; */
/* if (varid_in != varid) ERR; */
/* Write string. */
if (nc_put_var1_string(ncid, varid_in, index1, data_out)) ERR;
/* /\* Write string. *\/ */
/* if (nc_put_var1_string(ncid, varid_in, index1, data_out)) ERR; */
/* Get the string, check it, and free it. */
if (nc_get_var_string(ncid, varid_in, data_in)) ERR;
if (strcmp(data_in[0], data_out[0])) ERR;
if (nc_free_string(1, data_in)) ERR;
/* /\* Get the string, check it, and free it. *\/ */
/* if (nc_get_var_string(ncid, varid_in, data_in)) ERR; */
/* if (strcmp(data_in[0], data_out[0])) ERR; */
/* if (nc_free_string(1, data_in)) ERR; */
/* Close the file. */
if (nc_close(ncid)) ERR;
/* /\* Close the file. *\/ */
/* if (nc_close(ncid)) ERR; */
/* Now re-open file, read data, and check values again. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
/* /\* Now re-open file, read data, and check values again. *\/ */
/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */
/* Get the string, check it, and free it. */
if (nc_get_var_string(ncid, varid_in, data_in)) ERR;
if (strcmp(data_in[0], data_out[0])) ERR;
if (nc_free_string(1, data_in)) ERR;
/* /\* Get the string, check it, and free it. *\/ */
/* if (nc_get_var_string(ncid, varid_in, data_in)) ERR; */
/* if (strcmp(data_in[0], data_out[0])) ERR; */
/* if (nc_free_string(1, data_in)) ERR; */
/* Close the file. */
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* /\* Close the file. *\/ */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
printf("*** testing fill values of one var...");
{
#define V1_NAME "v1"
@ -96,6 +96,7 @@ main(int argc, char **argv)
char vals[MAX_VALS];
int i;
nc_set_log_level(4);
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
/* Define dimensions and two vars, a 1D coordinate var for

View File

@ -14,7 +14,8 @@
#define PARAMS_ID 32768
/* The C standard apparently defines all floating point constants as double;
we rely on that in this code.
we rely on that in this code. Update: apparently not true when
-ansi flag is used.
*/
#define DBLVAL 12345678.12345678
@ -25,12 +26,11 @@ static unsigned int baseline[NPARAMS];
/* Expected contents of baseline:
id = 32768
params = 4294967279, 23, 4294967271, 27, 77, 93, 1145389056, 3287505826, 1097305129, 1, 2147483648, 4294967295, 4294967295
params = 4294967279, 23, 4294967271, 27, 77, 93, 1145389056, 3287505826, 1097305129, 1, 2147483647, 4294967295U, 4294967295U
*/
static const char* spec =
"32768, -17b, 23ub, -25S, 27US, 77, 93U, 789f, 12345678.12345678d, -9223372036854775807L, 18446744073709551615UL, 2147483647, -2147483648, 4294967295";
"32768, -17b, 23ub, -25S, 27US, 77, 93U, 789f, 12345678.12345678d, -9223372036854775807L, 18446744073709551615UL, 2147483647, -2147483648, 4294967295U";
/* Test support for the conversions */
/* Not sure if this kind of casting via union is legal C99 */
@ -55,7 +55,7 @@ static int nerrs = 0;
static void
mismatch(size_t i, unsigned int *params, const char* tag)
{
fprintf(stderr,"mismatch: %s [%d] baseline=%ud params=%u\n",tag,(int)i,baseline[i],params[i]);
fprintf(stderr,"mismatch: %s [%d] baseline=%u params=%u\n",tag,(int)i,baseline[i],params[i]);
fflush(stderr);
nerrs++;
}
@ -63,7 +63,7 @@ mismatch(size_t i, unsigned int *params, const char* tag)
static void
mismatch2(size_t i, unsigned int *params, const char* tag)
{
fprintf(stderr,"mismatch2: %s [%ld-%ld] baseline=%ud,%ud params=%u,%u\n",
fprintf(stderr,"mismatch2: %s [%ld-%ld] baseline=%u,%u params=%u,%u\n",
tag,(long)i,(long)(i+1),baseline[i],baseline[i+1],params[i],params[i+1]);
fflush(stderr);
nerrs++;
@ -106,9 +106,9 @@ buildbaseline(void)
insert(11,&val8,sizeof(val8)); /* 11 unsigned long long */
val4 = 2147483647;
insert(13,&val4,sizeof(val4)); /* 13 signed int */
val4 = -2147483648;
val4 = (-2147483647)-1;
insert(14,&val4,sizeof(val4)); /* 14 signed int */
val4 = 4294967295;
val4 = 4294967295U;
insert(15,&val4,sizeof(val4)); /* 15 unsigned int */
}
@ -145,7 +145,7 @@ main(int argc, char **argv)
#ifdef WORD_BIGENDIAN
byteswap8((unsigned char*)&ud.d);
#endif
if(ud.d != DBLVAL)
if(ud.d != (double)DBLVAL)
mismatch2(7,params,"ud.d");
ul.ui[0] = params[9];
ul.ui[1] = params[10];

View File

@ -120,11 +120,11 @@ main(int argc, char **argv)
/* Create a file with one group, a group to contain data about
* Henry VII. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_var(ncid, HENRY_IV, NC_INT, 0, NULL, NULL)) ERR;
if (nc_def_var(ncid, HENRY_IV, NC_INT, 0, NULL, NULL)) ERR;
/* Turn off define mode. It will automatically be turned back on
* when nc_def_grp is called. */
if (nc_enddef(ncid)) ERR;
if (nc_enddef(ncid)) ERR;
if (nc_def_grp(ncid, HENRY_VII, &henry_vii_id)) ERR;
/* Check it out. */
@ -377,7 +377,7 @@ main(int argc, char **argv)
if (nc_inq_grps(ncid, NULL, grpid_in)) ERR;
if (nc_inq_grpname(grpid_in[0], name_in)) ERR;
if (strcmp(name_in, HENRY_VII)) ERR;
if (nc_inq_grpname(grpid_in[0], NULL)) ERR;
if (nc_inq_grpname(grpid_in[0], NULL)) ERR;
if (grpid_in[0] != grp_ncid) ERR;
strcat(full_name, HENRY_VII);
if (nc_inq_grpname_full(grpid_in[0], &len, full_name_in)) ERR;
@ -443,7 +443,7 @@ main(int argc, char **argv)
if (nc_inq_grpname_full(grpid_in[0], &len1, NULL)) ERR;
if (len1 != strlen(full_name)) ERR;
if (nc_inq_grpname_full(grpid_in[0], &len, full_name_in1)) ERR;
if (strcmp(full_name_in1, full_name)) ERR;
if (strcmp(full_name_in1, full_name)) ERR;
if (nc_close(ncid)) ERR;

View File

@ -82,6 +82,7 @@ main()
int natts = 0;
nc_type type;
nc_set_log_level(4);
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
/* Check the root group's attributes are OK */

View File

@ -402,16 +402,16 @@ main(int argc, char **argv)
{
#define VAR_NAME "Britany"
#define NDIMS 2
#define NDIMS2 2
#define TEXT_LEN 15
#define D0_NAME "time"
#define D1_NAME "tl"
int ncid, nvars_in, varids_in[1];
int time_dimids[NDIMS], time_id;
size_t time_count[NDIMS], time_index[NDIMS] = {0, 0};
int time_dimids[NDIMS2], time_id;
size_t time_count[NDIMS2], time_index[NDIMS2] = {0, 0};
const char ttext[TEXT_LEN]="20051224.150000";
int nvars, ndims, ngatts, unlimdimid;
int ndims_in, natts_in, dimids_in[NDIMS];
int ndims_in, natts_in, dimids_in[NDIMS2];
char var_name_in[NC_MAX_NAME + 1];
nc_type xtype_in;
@ -420,7 +420,7 @@ main(int argc, char **argv)
if (nc_def_dim(ncid, D0_NAME, NC_UNLIMITED, &time_dimids[0])) ERR;
if (nc_def_dim(ncid, D1_NAME, TEXT_LEN, &time_dimids[1])) ERR;
if (nc_def_var(ncid, D0_NAME, NC_CHAR, NDIMS, time_dimids, &time_id)) ERR;
if (nc_def_var(ncid, D0_NAME, NC_CHAR, NDIMS2, time_dimids, &time_id)) ERR;
/* Write one time to the coordinate variable. */
time_count[0] = 1;

View File

@ -12,6 +12,7 @@ See \ref copyright file for more info.
See https://bugtracking.unidata.ucar.edu/browse/NCF-326
for more information.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <netcdf.h>

View File

@ -69,8 +69,8 @@ int main(int argc, char *argv[])
unsigned char ubyte_data_out[] = {0,1,2,3,4};
unsigned short ushort_data_out[] = {0,11,22,33,44};
unsigned int uint_data_out[] = {0,111,222,333,3000000000u};
long long int int64_data_out[] = {0,-111111111,2222222222,-3333333333,444444444};
unsigned long long int uint64_data_out[] = {0,111111111,2222222222,33333333,44444444};
long long int int64_data_out[] = {0,-1111111111,222222222,-3333333333LL,444444444LL};
unsigned long long int uint64_data_out[] = {0,111111111,222222222,33333333,44444444};
/* We will read back in the phoney data with these. */
unsigned char ubyte_data_in[SIZE];

View File

@ -387,6 +387,7 @@ main(int argc, char **argv)
{
int ncid, dimid[NDIMS2], varid;
size_t start[NDIMS2] = {0, 0}, count[NDIMS2] = {NX, NY};
ptrdiff_t stride[NDIMS2] = {1, 1};
double double_data[NX * NY];
/* Create file with two dims, one 2D var. */
@ -400,6 +401,10 @@ main(int argc, char **argv)
if (nc_put_vara_double(ncid + MILLION, 0, start, count, double_data) != NC_EBADID) ERR;
if (nc_put_vara_double(ncid + TEST_VAL_42, 0, start, count, double_data) != NC_EBADID) ERR;
/* Write some data. */
if (nc_put_vars_double(ncid, varid, start, count, NULL, double_data)) ERR;
if (nc_put_vars_double(ncid, varid, start, count, stride, double_data)) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;

View File

@ -24,147 +24,147 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing netcdf-4 variable functions, even more.\n");
printf("**** testing Jeff's dimension problem...");
{
int varid, ncid, dims[NDIMS2], dims_in[NDIMS2];
int ndims, nvars, ngatts, unlimdimid, natts;
char name_in[NC_MAX_NAME + 1];
nc_type type_in;
size_t len_in;
/* printf("**** testing Jeff's dimension problem..."); */
/* { */
/* int varid, ncid, dims[NDIMS2], dims_in[NDIMS2]; */
/* int ndims, nvars, ngatts, unlimdimid, natts; */
/* char name_in[NC_MAX_NAME + 1]; */
/* nc_type type_in; */
/* size_t len_in; */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 ||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR;
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR;
if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR;
if (strcmp(name_in, Y_NAME)) ERR;
if (len_in != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; */
/* if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; */
/* if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 || */
/* dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR; */
/* if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR; */
/* if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR; */
/* if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR; */
/* if (strcmp(name_in, Y_NAME)) ERR; */
/* if (len_in != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR;
if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 ||
dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR;
if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR;
if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR;
if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR;
if (strcmp(name_in, Y_NAME)) ERR;
if (len_in != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing chunking turned on by fletcher...");
{
int varid, ncid, dims[NDIMS2];
int storage_in;
size_t chunksizes_in[NDIMS2];
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR; */
/* if (nvars != NUM_VARS || ndims != NDIMS2 || ngatts != 0 || unlimdimid != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &type_in, &ndims, dims_in, &natts)) ERR; */
/* if (strcmp(name_in, VAR_NAME) || type_in != NC_FLOAT || ndims != NDIMS2 || */
/* dims_in[0] != dims[0] || dims_in[1] != dims[1] || natts != 0) ERR; */
/* if (nc_inq_dim(ncid, 0, name_in, &len_in)) ERR; */
/* if (strcmp(name_in, X_NAME) || len_in != XDIM_LEN) ERR; */
/* if (nc_inq_dim(ncid, 1, name_in, &len_in)) ERR; */
/* if (strcmp(name_in, Y_NAME)) ERR; */
/* if (len_in != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
/* printf("**** testing chunking turned on by fletcher..."); */
/* { */
/* int varid, ncid, dims[NDIMS2]; */
/* int storage_in; */
/* size_t chunksizes_in[NDIMS2]; */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
if (nc_def_var_fletcher32(ncid, varid, NC_FLETCHER32)) ERR;
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
/* if (nc_def_var_fletcher32(ncid, varid, NC_FLETCHER32)) ERR; */
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing chunking turned on by shuffle...");
{
int varid, ncid, dims[NDIMS2];
int storage_in;
size_t chunksizes_in[NDIMS2];
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
/* printf("**** testing chunking turned on by shuffle..."); */
/* { */
/* int varid, ncid, dims[NDIMS2]; */
/* int storage_in; */
/* size_t chunksizes_in[NDIMS2]; */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR;
if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR;
if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR;
if (nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 0, 0)) ERR;
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
/* if (nc_def_dim(ncid, X_NAME, XDIM_LEN, &dims[0])) ERR; */
/* if (nc_def_dim(ncid, Y_NAME, YDIM_LEN, &dims[1])) ERR; */
/* if (nc_def_var(ncid, VAR_NAME, NC_FLOAT, 2, dims, &varid)) ERR; */
/* if (nc_def_var_deflate(ncid, varid, NC_SHUFFLE, 0, 0)) ERR; */
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR;
if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
#define DIM_NAME "Distance_from_Mayo"
#define VAR_NAME_2 "Rocky_Road_to_Dublin"
#define NDIMS1 1
#define NUM_RECORDS 3
printf("**** testing extending var along unlimited dim with no coord var...");
{
int varid, ncid, dimid;
int ndims, nvars, natts, unlimdimid;
size_t dim_len_in, index;
int data = TEST_VAL_42;
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq_var_chunking(ncid, varid, &storage_in, chunksizes_in)) ERR; */
/* if (chunksizes_in[0] != XDIM_LEN || chunksizes_in[1] != YDIM_LEN) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
/* #define DIM_NAME "Distance_from_Mayo" */
/* #define VAR_NAME_2 "Rocky_Road_to_Dublin" */
/* #define NDIMS1 1 */
/* #define NUM_RECORDS 3 */
/* printf("**** testing extending var along unlimited dim with no coord var..."); */
/* { */
/* int varid, ncid, dimid; */
/* int ndims, nvars, natts, unlimdimid; */
/* size_t dim_len_in, index; */
/* int data = TEST_VAL_42; */
/* Create the test file with one var, one unlimited dim. */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, &dimid)) ERR;
if (nc_def_var(ncid, VAR_NAME_2, NC_INT, NDIMS1, &dimid, &varid)) ERR;
/* /\* Create the test file with one var, one unlimited dim. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
/* if (nc_def_dim(ncid, DIM_NAME, NC_UNLIMITED, &dimid)) ERR; */
/* if (nc_def_var(ncid, VAR_NAME_2, NC_INT, NDIMS1, &dimid, &varid)) ERR; */
/* Write some records. */
for (index = 0; index < NUM_RECORDS; index++)
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
if (nc_close(ncid)) ERR;
/* /\* Write some records. *\/ */
/* for (index = 0; index < NUM_RECORDS; index++) */
/* if (nc_put_var1_int(ncid, varid, &index, &data)) ERR; */
/* if (nc_close(ncid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != 0) ERR;
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
if (dim_len_in != NUM_RECORDS) ERR;
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR; */
/* if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != 0) ERR; */
/* if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR; */
/* if (dim_len_in != NUM_RECORDS) ERR; */
/* Now add more records. */
for (index = 3; index < NUM_RECORDS * 2; index++)
if (nc_put_var1_int(ncid, varid, &index, &data)) ERR;
if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR;
/* /\* Now add more records. *\/ */
/* for (index = 3; index < NUM_RECORDS * 2; index++) */
/* if (nc_put_var1_int(ncid, varid, &index, &data)) ERR; */
/* if (nc_inq_dim(ncid, dimid, NULL, &dim_len_in)) ERR; */
if (dim_len_in != NUM_RECORDS * 2) ERR;
/* if (dim_len_in != NUM_RECORDS * 2) ERR; */
/* Close the file. */
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing type creation and destruction for atomic types...");
{
int varid1, varid2, ncid;
int ndims, nvars, natts, unlimdimid;
/* /\* Close the file. *\/ */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
/* printf("**** testing type creation and destruction for atomic types..."); */
/* { */
/* int varid1, varid2, ncid; */
/* int ndims, nvars, natts, unlimdimid; */
/* Create the test file with two scalar vars. */
/* nc_set_log_level(4); */
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
if (nc_def_var(ncid, CLAIR, NC_INT, 0, NULL, &varid1)) ERR;
if (nc_def_var(ncid, JAMIE, NC_INT, 0, NULL, &varid2)) ERR;
if (nc_close(ncid)) ERR;
/* /\* Create the test file with two scalar vars. *\/ */
/* /\* nc_set_log_level(4); *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; */
/* if (nc_def_var(ncid, CLAIR, NC_INT, 0, NULL, &varid1)) ERR; */
/* if (nc_def_var(ncid, JAMIE, NC_INT, 0, NULL, &varid2)) ERR; */
/* if (nc_close(ncid)) ERR; */
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != 0 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* /\* Open the file and check. *\/ */
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR; */
/* if (ndims != 0 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR; */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
printf("**** testing scalar big endian vars...");
{
int varid1, varid2, ncid;
@ -186,14 +186,14 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
/* Open the file and check. */
if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != 0 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR;
if (nc_get_var(ncid, varid1, &data_in)) ERR;
if (data_in != TEST_VAL_42) ERR;
if (nc_get_var(ncid, varid2, &data_in)) ERR;
if (data_in != TEST_VAL_42 * 2) ERR;
if (nc_close(ncid)) ERR;
/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */
/* if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR; */
/* if (ndims != 0 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR; */
/* if (nc_get_var(ncid, varid1, &data_in)) ERR; */
/* if (data_in != TEST_VAL_42) ERR; */
/* if (nc_get_var(ncid, varid2, &data_in)) ERR; */
/* if (data_in != TEST_VAL_42 * 2) ERR; */
/* if (nc_close(ncid)) ERR; */
}
SUMMARIZE_ERR;
FINAL_RESULTS;

File diff suppressed because it is too large Load Diff

View File

@ -18,8 +18,7 @@ Research/Unidata. See \ref copyright file for more info. */
#include <fcntl.h>
#endif
#ifdef _MSC_VER
#define snprintf _snprintf
#ifdef _WIN32
#include "XGetopt.h"
int opterr;
int optind;
@ -1107,7 +1106,9 @@ pr_att_hidden(
size_t len;
/* No special variable attributes for classic or 64-bit offset data */
/*if(kind == 1 || kind == 2) return; */
#if 0
if(kind == 1 || kind == 2) return;
#endif
/* Print out Selected hidden attributes */
/* NCPROPS */
stat = nc_inq_att(ncid,NC_GLOBAL,NCPROPS,NULL,&len);

View File

@ -18,26 +18,22 @@
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include "oc.h"
#include "ocx.h"
/* Utilities */
#include "netcdf.h"
#include "ncuri.h"
#include "ncbytes.h"
#include "nclog.h"
#ifdef WIN32
/*#include <windows.h>*/
#define snprintf _snprintf
#define strcasecmp stricmp
#endif
#include "oc.h"
#include "ocx.h"
#ifdef _MSC_VER
#ifdef _WIN32
#include "XGetopt.h"
int opterr;
int optind;
int opterr, optind;
char* optarg;
#endif
#ifndef nulldup

View File

@ -13,6 +13,9 @@
#include <assert.h>
#include <ctype.h>
#include "utils.h"
#ifndef isascii
EXTERNL int isascii(int c);
#endif
/*
* Print error message to stderr and exit

View File

@ -56,10 +56,11 @@ CLEANFILES = c0.nc c0_64.nc c0_4.nc c0_4c.nc ref_camrun.c \
# not want to other to ./configure.
makeparser::
rm -f ncgenl.c lex.ncg.c
flex -Pncg -8 ncgen.l
rm -f ncgenl.c
sed -e s/lex.ncg.c/ncgenl.c/g <lex.ncg.c >ncgenl.c
bison -pncg -t -d ncgen.y
rm -f ncgeny.c ncgeny.h
rm -f ncgeny.c ncgeny.h
sed -e s/ncgen.tab.c/ncgeny.c/g -e s/ncgen.tab.h/ncgeny.h/g <ncgen.tab.c >ncgeny.c
sed -e s/ncgen.tab.c/ncgeny.c/g -e s/ncgen.tab.h/ncgeny.h/g <ncgen.tab.h >ncgeny.h
rm -f lex.ncg.c ncgen.tab.h ncgen.tab.c

View File

@ -9,6 +9,9 @@
#ifdef ENABLE_C
#include <math.h>
#ifndef isnan
extern int isnan(double);
#endif
static int c_uid = 0;

View File

@ -7,6 +7,10 @@
#include "includes.h"
#include <ctype.h> /* for isprint() */
#ifndef vsnprintf
extern int vsnprintf(char*, size_t, const char*, va_list ap);
#endif
int error_count;
#if 0

View File

@ -9,6 +9,9 @@
#ifdef ENABLE_JAVA
#include <math.h>
#ifndef isnan
extern int isnan(double);
#endif
static int j_uid = 0;

View File

@ -14,7 +14,6 @@
#ifdef _MSC_VER
#include "XGetopt.h"
#define snprintf _snprintf
int opterr;
int optind;
#endif
@ -298,7 +297,9 @@ main(
derror("%s: output language is null", progname);
return(1);
}
/*lang_name = estrdup(optarg);*/
#if 0
lang_name = estrdup(optarg);
#endif
lang_name = (char*) emalloc(strlen(optarg)+1);
(void)strcpy(lang_name, optarg);

View File

@ -38,6 +38,8 @@
#include "ncgen.h"
#include "ncgeny.h"
EXTERNL int fileno(FILE*);
#define FILL_STRING "_"
#define XDR_INT32_MIN (-2147483647-1)
#define XDR_INT32_MAX 2147483647

View File

@ -52,7 +52,7 @@
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
@ -69,7 +69,7 @@ typedef uint32_t flex_uint32_t;
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
@ -195,7 +195,7 @@ extern FILE *ncgin, *ncgout;
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
@ -252,7 +252,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@ -1204,6 +1204,8 @@ char *ncgtext;
#include "ncgen.h"
#include "ncgeny.h"
EXTERNL int fileno(FILE*);
#define FILL_STRING "_"
#define XDR_INT32_MIN (-2147483647-1)
#define XDR_INT32_MAX 2147483647
@ -1345,7 +1347,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 1349 "ncgenl.c"
#line 1351 "ncgenl.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@ -1407,9 +1409,9 @@ extern int ncgwrap (void );
#endif
#ifndef YY_NO_UNPUT
static void yyunput (int c,char *buf_ptr );
#endif
#ifndef yytext_ptr
@ -1537,7 +1539,7 @@ YY_DECL
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
if ( !(yy_init) )
{
(yy_init) = 1;
@ -1565,9 +1567,9 @@ YY_DECL
}
{
#line 218 "ncgen.l"
#line 220 "ncgen.l"
#line 1571 "ncgenl.c"
#line 1573 "ncgenl.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@ -1626,14 +1628,14 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 219 "ncgen.l"
#line 221 "ncgen.l"
{ /* whitespace */
break;
}
YY_BREAK
case 2:
YY_RULE_SETUP
#line 223 "ncgen.l"
#line 225 "ncgen.l"
{ /* comment */
break;
}
@ -1641,7 +1643,7 @@ YY_RULE_SETUP
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
#line 227 "ncgen.l"
#line 229 "ncgen.l"
{int len; char* s = NULL;
/* In netcdf4, this will be used in a variety
of places, so only remove escapes */
@ -1665,7 +1667,7 @@ ncgtext[MAXTRST-1] = '\0';
YY_BREAK
case 4:
YY_RULE_SETUP
#line 248 "ncgen.l"
#line 250 "ncgen.l"
{ /* drop leading 0x; pad to even number of chars */
char* p = ncgtext+2;
int len = ncgleng - 2;
@ -1680,118 +1682,118 @@ YY_RULE_SETUP
YY_BREAK
case 5:
YY_RULE_SETUP
#line 260 "ncgen.l"
#line 262 "ncgen.l"
{return lexdebug(COMPOUND);}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 261 "ncgen.l"
#line 263 "ncgen.l"
{return lexdebug(ENUM);}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 262 "ncgen.l"
#line 264 "ncgen.l"
{return lexdebug(OPAQUE_);}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 264 "ncgen.l"
#line 266 "ncgen.l"
{return lexdebug(FLOAT_K);}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 265 "ncgen.l"
#line 267 "ncgen.l"
{return lexdebug(CHAR_K);}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 266 "ncgen.l"
#line 268 "ncgen.l"
{return lexdebug(BYTE_K);}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 267 "ncgen.l"
#line 269 "ncgen.l"
{return lexdebug(UBYTE_K);}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 268 "ncgen.l"
#line 270 "ncgen.l"
{return lexdebug(SHORT_K);}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 269 "ncgen.l"
#line 271 "ncgen.l"
{return lexdebug(USHORT_K);}
YY_BREAK
case 14:
YY_RULE_SETUP
#line 270 "ncgen.l"
#line 272 "ncgen.l"
{return lexdebug(INT_K);}
YY_BREAK
case 15:
YY_RULE_SETUP
#line 271 "ncgen.l"
#line 273 "ncgen.l"
{return lexdebug(UINT_K);}
YY_BREAK
case 16:
YY_RULE_SETUP
#line 272 "ncgen.l"
#line 274 "ncgen.l"
{return lexdebug(INT64_K);}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 273 "ncgen.l"
#line 275 "ncgen.l"
{return lexdebug(UINT64_K);}
YY_BREAK
case 18:
YY_RULE_SETUP
#line 274 "ncgen.l"
#line 276 "ncgen.l"
{return lexdebug(DOUBLE_K);}
YY_BREAK
case 19:
YY_RULE_SETUP
#line 275 "ncgen.l"
#line 277 "ncgen.l"
{return lexdebug(STRING_K);}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 277 "ncgen.l"
#line 279 "ncgen.l"
{int32_val = -1;
return lexdebug(NC_UNLIMITED_K);}
YY_BREAK
case 21:
YY_RULE_SETUP
#line 280 "ncgen.l"
#line 282 "ncgen.l"
{return lexdebug(TYPES);}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 281 "ncgen.l"
#line 283 "ncgen.l"
{return lexdebug(DIMENSIONS);}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 282 "ncgen.l"
#line 284 "ncgen.l"
{return lexdebug(VARIABLES);}
YY_BREAK
case 24:
YY_RULE_SETUP
#line 283 "ncgen.l"
#line 285 "ncgen.l"
{return lexdebug(DATA);}
YY_BREAK
case 25:
YY_RULE_SETUP
#line 284 "ncgen.l"
#line 286 "ncgen.l"
{return lexdebug(GROUP);}
YY_BREAK
case 26:
YY_RULE_SETUP
#line 286 "ncgen.l"
#line 288 "ncgen.l"
{BEGIN(TEXT);return lexdebug(NETCDF);}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 288 "ncgen.l"
#line 290 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */
if (ncgtext[0] == '-') {
double_val = NEGNC_INFINITE;
@ -1804,7 +1806,7 @@ YY_RULE_SETUP
YY_BREAK
case 28:
YY_RULE_SETUP
#line 297 "ncgen.l"
#line 299 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */
double_val = NAN;
specialconstants = 1;
@ -1813,7 +1815,7 @@ YY_RULE_SETUP
YY_BREAK
case 29:
YY_RULE_SETUP
#line 303 "ncgen.l"
#line 305 "ncgen.l"
{/* missing value (pre-2.4 backward compatibility)*/
if (ncgtext[0] == '-') {
float_val = NEGNC_INFINITEF;
@ -1826,7 +1828,7 @@ YY_RULE_SETUP
YY_BREAK
case 30:
YY_RULE_SETUP
#line 312 "ncgen.l"
#line 314 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */
float_val = NANF;
specialconstants = 1;
@ -1835,7 +1837,7 @@ YY_RULE_SETUP
YY_BREAK
case 31:
YY_RULE_SETUP
#line 318 "ncgen.l"
#line 320 "ncgen.l"
{
#ifdef USE_NETCDF4
if(l_flag == L_C || l_flag == L_BINARY)
@ -1848,7 +1850,7 @@ YY_RULE_SETUP
YY_BREAK
case 32:
YY_RULE_SETUP
#line 328 "ncgen.l"
#line 330 "ncgen.l"
{
bbClear(lextext);
bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */
@ -1859,7 +1861,7 @@ YY_RULE_SETUP
YY_BREAK
case 33:
YY_RULE_SETUP
#line 337 "ncgen.l"
#line 339 "ncgen.l"
{struct Specialtoken* st;
bbClear(lextext);
bbAppendn(lextext,(char*)ncgtext,ncgleng+1); /* include null */
@ -1873,7 +1875,7 @@ YY_RULE_SETUP
case 34:
/* rule 34 can match eol */
YY_RULE_SETUP
#line 347 "ncgen.l"
#line 349 "ncgen.l"
{
int c;
char* p; char* q;
@ -1893,7 +1895,7 @@ YY_RULE_SETUP
YY_BREAK
case 35:
YY_RULE_SETUP
#line 364 "ncgen.l"
#line 366 "ncgen.l"
{ char* id = NULL; int len;
len = strlen(ncgtext);
len = unescape(ncgtext,len,ISIDENT,&id);
@ -1908,7 +1910,7 @@ YY_RULE_SETUP
YY_BREAK
case 36:
YY_RULE_SETUP
#line 376 "ncgen.l"
#line 378 "ncgen.l"
{
/*
We need to try to see what size of integer ((u)int).
@ -1976,7 +1978,7 @@ done: return 0;
YY_BREAK
case 37:
YY_RULE_SETUP
#line 441 "ncgen.l"
#line 443 "ncgen.l"
{
int c;
int token = 0;
@ -2027,7 +2029,7 @@ YY_RULE_SETUP
YY_BREAK
case 38:
YY_RULE_SETUP
#line 488 "ncgen.l"
#line 490 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%le", &double_val) != 1) {
sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext);
@ -2038,7 +2040,7 @@ YY_RULE_SETUP
YY_BREAK
case 39:
YY_RULE_SETUP
#line 495 "ncgen.l"
#line 497 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%e", &float_val) != 1) {
sprintf(errstr,"bad float constant: %s",(char*)ncgtext);
@ -2050,7 +2052,7 @@ YY_RULE_SETUP
case 40:
/* rule 40 can match eol */
YY_RULE_SETUP
#line 502 "ncgen.l"
#line 504 "ncgen.l"
{
(void) sscanf((char*)&ncgtext[1],"%c",&byte_val);
return lexdebug(BYTE_CONST);
@ -2058,7 +2060,7 @@ YY_RULE_SETUP
YY_BREAK
case 41:
YY_RULE_SETUP
#line 506 "ncgen.l"
#line 508 "ncgen.l"
{
int oct = unescapeoct(&ncgtext[2]);
if(oct < 0) {
@ -2071,7 +2073,7 @@ YY_RULE_SETUP
YY_BREAK
case 42:
YY_RULE_SETUP
#line 515 "ncgen.l"
#line 517 "ncgen.l"
{
int hex = unescapehex(&ncgtext[3]);
if(byte_val < 0) {
@ -2084,7 +2086,7 @@ YY_RULE_SETUP
YY_BREAK
case 43:
YY_RULE_SETUP
#line 524 "ncgen.l"
#line 526 "ncgen.l"
{
switch ((char)ncgtext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under-
@ -2106,7 +2108,7 @@ YY_RULE_SETUP
case 44:
/* rule 44 can match eol */
YY_RULE_SETUP
#line 542 "ncgen.l"
#line 544 "ncgen.l"
{
lineno++ ;
break;
@ -2114,7 +2116,7 @@ YY_RULE_SETUP
YY_BREAK
case 45:
YY_RULE_SETUP
#line 547 "ncgen.l"
#line 549 "ncgen.l"
{/*initial*/
BEGIN(ST_C_COMMENT);
break;
@ -2123,21 +2125,21 @@ YY_RULE_SETUP
case 46:
/* rule 46 can match eol */
YY_RULE_SETUP
#line 552 "ncgen.l"
#line 554 "ncgen.l"
{/* continuation */
break;
}
YY_BREAK
case 47:
YY_RULE_SETUP
#line 556 "ncgen.l"
#line 558 "ncgen.l"
{/* final */
BEGIN(INITIAL);
break;
}
YY_BREAK
case YY_STATE_EOF(ST_C_COMMENT):
#line 561 "ncgen.l"
#line 563 "ncgen.l"
{/* final, error */
fprintf(stderr,"unterminated /**/ comment");
BEGIN(INITIAL);
@ -2146,17 +2148,17 @@ case YY_STATE_EOF(ST_C_COMMENT):
YY_BREAK
case 48:
YY_RULE_SETUP
#line 567 "ncgen.l"
#line 569 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */
return lexdebug(ncgtext[0]) ;
}
YY_BREAK
case 49:
YY_RULE_SETUP
#line 570 "ncgen.l"
#line 572 "ncgen.l"
ECHO;
YY_BREAK
#line 2160 "ncgenl.c"
#line 2162 "ncgenl.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -2436,7 +2438,7 @@ static int yy_get_next_buffer (void)
{
yy_state_type yy_current_state;
char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
@ -2492,7 +2494,7 @@ static int yy_get_next_buffer (void)
static void yyunput (int c, char * yy_bp )
{
char *yy_cp;
yy_cp = (yy_c_buf_p);
/* undo effects of setting up ncgtext */
@ -2537,7 +2539,7 @@ static int yy_get_next_buffer (void)
{
int c;
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
@ -2604,12 +2606,12 @@ static int yy_get_next_buffer (void)
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
*
* @note This function does not reset the start condition to @c INITIAL .
*/
void ncgrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
ncgensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
@ -2622,11 +2624,11 @@ static int yy_get_next_buffer (void)
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*
*/
void ncg_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
/* TODO. We should be able to replace this entire function body
* with
* ncgpop_buffer_state();
@ -2666,13 +2668,13 @@ static void ncg_load_buffer_state (void)
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
*
* @return the allocated buffer state.
*/
YY_BUFFER_STATE ncg_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) ncgalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" );
@ -2695,11 +2697,11 @@ static void ncg_load_buffer_state (void)
/** Destroy the buffer.
* @param b a buffer created with ncg_create_buffer()
*
*
*/
void ncg_delete_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
@ -2720,7 +2722,7 @@ static void ncg_load_buffer_state (void)
{
int oerrno = errno;
ncg_flush_buffer(b );
b->yy_input_file = file;
@ -2736,13 +2738,13 @@ static void ncg_load_buffer_state (void)
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*
*/
void ncg_flush_buffer (YY_BUFFER_STATE b )
{
@ -2771,7 +2773,7 @@ static void ncg_load_buffer_state (void)
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*
*/
void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer )
{
@ -2801,7 +2803,7 @@ void ncgpush_buffer_state (YY_BUFFER_STATE new_buffer )
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*
*/
void ncgpop_buffer_state (void)
{
@ -2825,7 +2827,7 @@ void ncgpop_buffer_state (void)
static void ncgensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
@ -2838,9 +2840,9 @@ static void ncgensure_buffer_stack (void)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in ncgensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
@ -2868,13 +2870,13 @@ static void ncgensure_buffer_stack (void)
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
@ -2903,14 +2905,14 @@ YY_BUFFER_STATE ncg_scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to ncglex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
*
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* ncg_scan_bytes() instead.
*/
YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr )
{
return ncg_scan_bytes(yystr,strlen(yystr) );
}
@ -2918,7 +2920,7 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr )
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
@ -2927,7 +2929,7 @@ YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
char *buf;
yy_size_t n;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
buf = (char *) ncgalloc(n );
@ -2981,16 +2983,16 @@ static void yy_fatal_error (yyconst char* msg )
/* Accessor methods (get/set functions) to struct members. */
/** Get the current line number.
*
*
*/
int ncgget_lineno (void)
{
return ncglineno;
}
/** Get the input stream.
*
*
*/
FILE *ncgget_in (void)
{
@ -2998,7 +3000,7 @@ FILE *ncgget_in (void)
}
/** Get the output stream.
*
*
*/
FILE *ncgget_out (void)
{
@ -3006,7 +3008,7 @@ FILE *ncgget_out (void)
}
/** Get the length of the current token.
*
*
*/
yy_size_t ncgget_leng (void)
{
@ -3014,7 +3016,7 @@ yy_size_t ncgget_leng (void)
}
/** Get the current token.
*
*
*/
char *ncgget_text (void)
@ -3024,18 +3026,18 @@ char *ncgget_text (void)
/** Set the current line number.
* @param _line_number line number
*
*
*/
void ncgset_lineno (int _line_number )
{
ncglineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
*
*
* @see ncg_switch_to_buffer
*/
void ncgset_in (FILE * _in_str )
@ -3089,7 +3091,7 @@ static int yy_init_globals (void)
/* ncglex_destroy is for both reentrant and non-reentrant scanners. */
int ncglex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
ncg_delete_buffer(YY_CURRENT_BUFFER );
@ -3115,7 +3117,7 @@ int ncglex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
@ -3140,7 +3142,7 @@ void *ncgalloc (yy_size_t size )
void *ncgrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@ -3158,7 +3160,8 @@ void ncgfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 570 "ncgen.l"
#line 572 "ncgen.l"
static int
@ -3450,4 +3453,3 @@ collecttag(char* text, char** stagp)
}
return tag;
}

View File

@ -661,19 +661,3 @@ kind_string(int kind)
}
return NULL;
}
#ifdef USE_NETCDF4i
nt
getrootid(int grpid)
{
int current = grpid;
int parent = current;
/* see if root id */
for(;;) {
int stat = nc_inq_grp_parent(current,&parent);
if(stat) break;
current = parent;
}
return current;
}
#endif

View File

@ -25,6 +25,8 @@
We include lexical definitions for all three, but use the second version.
*/
extern int fileno(FILE*);
/* lex specification for tokens for ncgen */
/* Fill value used by ncdump from version 2.4 and later. Should match
@ -288,6 +290,7 @@ FloatInf|-?Inff { /* missing value (pre-2.4 backward compatibility) */
void
ignore()
{
#ifndef YY_NO_UNPUT
yyunput(0,NULL);
#endif
}

View File

@ -13,11 +13,14 @@ static char SccsId[] = "$Id: ncgen.y,v 1.34 2010/03/31 18:18:41 dmh Exp $";
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "netcdf.h"
#include "generic.h"
#include "ncgen.h"
#include "genlib.h" /* for grow_darray() et al */
extern int fileno(FILE*);
typedef struct Symbol { /* symbol table entry */
char *name;
struct Symbol *next;

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.6.4. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_NCG_NCGEN_TAB_H_INCLUDED
# define YY_NCG_NCGEN_TAB_H_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@ -40,57 +40,44 @@
extern int ncgdebug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
NC_UNLIMITED_K = 258,
BYTE_K = 259,
CHAR_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
IDENT = 265,
TERMSTRING = 266,
BYTE_CONST = 267,
CHAR_CONST = 268,
SHORT_CONST = 269,
INT_CONST = 270,
FLOAT_CONST = 271,
DOUBLE_CONST = 272,
DIMENSIONS = 273,
VARIABLES = 274,
NETCDF = 275,
DATA = 276,
FILLVALUE = 277
};
enum yytokentype
{
NC_UNLIMITED_K = 258,
BYTE_K = 259,
CHAR_K = 260,
SHORT_K = 261,
INT_K = 262,
FLOAT_K = 263,
DOUBLE_K = 264,
IDENT = 265,
TERMSTRING = 266,
BYTE_CONST = 267,
CHAR_CONST = 268,
SHORT_CONST = 269,
INT_CONST = 270,
FLOAT_CONST = 271,
DOUBLE_CONST = 272,
DIMENSIONS = 273,
VARIABLES = 274,
NETCDF = 275,
DATA = 276,
FILLVALUE = 277
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE ncglval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int ncgparse (void *YYPARSE_PARAM);
#else
int ncgparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int ncgparse (void);
#else
int ncgparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_NCG_NCGEN_TAB_H_INCLUDED */

View File

@ -26,8 +26,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 0
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -72,7 +72,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@ -103,6 +102,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@ -159,7 +160,15 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -171,7 +180,12 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
extern int ncgleng;
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t ncgleng;
extern FILE *ncgin, *ncgout;
@ -180,6 +194,7 @@ extern FILE *ncgin, *ncgout;
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@ -197,11 +212,6 @@ extern FILE *ncgin, *ncgout;
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -290,7 +300,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when ncgtext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int ncgleng;
yy_size_t ncgleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@ -318,7 +328,7 @@ static void ncg_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE ncg_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE ncg_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,int len );
YY_BUFFER_STATE ncg_scan_bytes (yyconst char *bytes,yy_size_t len );
void *ncgalloc (yy_size_t );
void *ncgrealloc (void *,yy_size_t );
@ -361,11 +371,17 @@ extern int ncglineno;
int ncglineno = 1;
extern char *ncgtext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr ncgtext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
#if defined(__GNUC__) && __GNUC__ >= 3
__attribute__((__noreturn__))
#endif
static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
@ -417,7 +433,7 @@ static yyconst flex_int16_t yy_accept[236] =
16, 11, 16, 10, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
static yyconst YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 4, 4, 1, 1, 1, 1, 1, 1, 1,
@ -449,7 +465,7 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[61] =
static yyconst YY_CHAR yy_meta[61] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 3, 4, 4,
4, 1, 5, 5, 5, 1, 4, 5, 5, 5,
@ -459,7 +475,7 @@ static yyconst flex_int32_t yy_meta[61] =
4, 4, 4, 4, 4, 7, 1, 4, 4, 4
} ;
static yyconst flex_int16_t yy_base[246] =
static yyconst flex_uint16_t yy_base[246] =
{ 0,
0, 0, 327, 1206, 59, 1206, 55, 277, 54, 59,
88, 295, 124, 165, 30, 57, 159, 61, 141, 149,
@ -521,7 +537,7 @@ static yyconst flex_int16_t yy_def[246] =
235, 235, 235, 235, 235
} ;
static yyconst flex_int16_t yy_nxt[1267] =
static yyconst flex_uint16_t yy_nxt[1267] =
{ 0,
4, 5, 6, 5, 5, 4, 7, 8, 9, 10,
11, 12, 13, 14, 14, 4, 4, 15, 15, 15,
@ -849,6 +865,8 @@ char *ncgtext;
We include lexical definitions for all three, but use the second version.
*/
extern int fileno(FILE*);
/* lex specification for tokens for ncgen */
/* Fill value used by ncdump from version 2.4 and later. Should match
@ -909,7 +927,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 913 "lex.ncg.c"
#line 931 "lex.ncg.c"
#define INITIAL 0
@ -942,19 +960,19 @@ void ncgset_extra (YY_EXTRA_TYPE user_defined );
FILE *ncgget_in (void );
void ncgset_in (FILE * in_str );
void ncgset_in (FILE * _in_str );
FILE *ncgget_out (void );
void ncgset_out (FILE * out_str );
void ncgset_out (FILE * _out_str );
int ncgget_leng (void );
yy_size_t ncgget_leng (void );
char *ncgget_text (void );
int ncgget_lineno (void );
void ncgset_lineno (int line_number );
void ncgset_lineno (int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -968,8 +986,12 @@ extern int ncgwrap (void );
#endif
#endif
#ifndef YY_NO_UNPUT
static void yyunput (int c,char *buf_ptr );
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
@ -990,7 +1012,12 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@ -1009,7 +1036,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
unsigned n; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( ncgin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -1077,7 +1104,7 @@ extern int ncglex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
@ -1087,14 +1114,10 @@ extern int ncglex (void);
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
#line 107 "ncgen.l"
#line 1097 "lex.ncg.c"
if ( !(yy_init) )
{
(yy_init) = 1;
@ -1121,7 +1144,12 @@ YY_DECL
ncg_load_buffer_state( );
}
while ( 1 ) /* loops until end-of-file is reached */
{
#line 109 "ncgen.l"
#line 1151 "lex.ncg.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@ -1137,7 +1165,7 @@ YY_DECL
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1178,7 +1206,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
#line 108 "ncgen.l"
#line 110 "ncgen.l"
{ /* comment */
break;
}
@ -1186,7 +1214,7 @@ YY_RULE_SETUP
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 112 "ncgen.l"
#line 114 "ncgen.l"
{
if(ncgleng > MAXTRST) {
yyerror("string too long, truncated\n");
@ -1198,59 +1226,59 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
#line 121 "ncgen.l"
#line 123 "ncgen.l"
{return (FLOAT_K);}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 122 "ncgen.l"
#line 124 "ncgen.l"
{return (CHAR_K);}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 123 "ncgen.l"
#line 125 "ncgen.l"
{return (BYTE_K);}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 124 "ncgen.l"
#line 126 "ncgen.l"
{return (SHORT_K);}
YY_BREAK
case 7:
YY_RULE_SETUP
#line 125 "ncgen.l"
#line 127 "ncgen.l"
{return (INT_K);}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 126 "ncgen.l"
#line 128 "ncgen.l"
{return (DOUBLE_K);}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 127 "ncgen.l"
#line 129 "ncgen.l"
{int_val = -1;
return (NC_UNLIMITED_K);}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 130 "ncgen.l"
#line 132 "ncgen.l"
{return (DIMENSIONS);}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 131 "ncgen.l"
#line 133 "ncgen.l"
{return (VARIABLES);}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 132 "ncgen.l"
#line 134 "ncgen.l"
{return (DATA);}
YY_BREAK
case 13:
/* rule 13 can match eol */
YY_RULE_SETUP
#line 133 "ncgen.l"
#line 135 "ncgen.l"
{
char *s = (char*)ncgtext+strlen("netcdf");
char *t = (char*)ncgtext+ncgleng-1;
@ -1272,7 +1300,7 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
#line 151 "ncgen.l"
#line 153 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */
if (ncgtext[0] == '-') {
double_val = -NC_FILL_DOUBLE;
@ -1284,7 +1312,7 @@ YY_RULE_SETUP
YY_BREAK
case 15:
YY_RULE_SETUP
#line 159 "ncgen.l"
#line 161 "ncgen.l"
{ /* missing value (pre-2.4 backward compatibility) */
if (ncgtext[0] == '-') {
float_val = -NC_FILL_FLOAT;
@ -1296,7 +1324,7 @@ YY_RULE_SETUP
YY_BREAK
case 16:
YY_RULE_SETUP
#line 167 "ncgen.l"
#line 169 "ncgen.l"
{
if (STREQ((char *)ncgtext, FILL_STRING))
return (FILLVALUE);
@ -1309,7 +1337,7 @@ YY_RULE_SETUP
case 17:
/* rule 17 can match eol */
YY_RULE_SETUP
#line 176 "ncgen.l"
#line 178 "ncgen.l"
{
lineno++ ;
break;
@ -1317,7 +1345,7 @@ YY_RULE_SETUP
YY_BREAK
case 18:
YY_RULE_SETUP
#line 181 "ncgen.l"
#line 183 "ncgen.l"
{
int ii;
if (sscanf((char*)ncgtext, "%d", &ii) != 1) {
@ -1334,7 +1362,7 @@ YY_RULE_SETUP
YY_BREAK
case 19:
YY_RULE_SETUP
#line 195 "ncgen.l"
#line 197 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%le", &double_val) != 1) {
sprintf(errstr,"bad long or double constant: %s",(char*)ncgtext);
@ -1345,7 +1373,7 @@ YY_RULE_SETUP
YY_BREAK
case 20:
YY_RULE_SETUP
#line 202 "ncgen.l"
#line 204 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%e", &float_val) != 1) {
sprintf(errstr,"bad float constant: %s",(char*)ncgtext);
@ -1356,7 +1384,7 @@ YY_RULE_SETUP
YY_BREAK
case 21:
YY_RULE_SETUP
#line 209 "ncgen.l"
#line 211 "ncgen.l"
{
if (sscanf((char*)ncgtext, "%hd", &short_val) != 1) {
sprintf(errstr,"bad short constant: %s",(char*)ncgtext);
@ -1367,7 +1395,7 @@ YY_RULE_SETUP
YY_BREAK
case 22:
YY_RULE_SETUP
#line 216 "ncgen.l"
#line 218 "ncgen.l"
{
char *ptr;
errno = 0;
@ -1386,7 +1414,7 @@ YY_RULE_SETUP
YY_BREAK
case 23:
YY_RULE_SETUP
#line 231 "ncgen.l"
#line 233 "ncgen.l"
{
char *ptr;
long long_val;
@ -1408,7 +1436,7 @@ YY_RULE_SETUP
case 24:
/* rule 24 can match eol */
YY_RULE_SETUP
#line 248 "ncgen.l"
#line 250 "ncgen.l"
{
(void) sscanf((char*)&ncgtext[1],"%c",&byte_val);
return (BYTE_CONST);
@ -1416,7 +1444,7 @@ YY_RULE_SETUP
YY_BREAK
case 25:
YY_RULE_SETUP
#line 252 "ncgen.l"
#line 254 "ncgen.l"
{
byte_val = (char) strtol((char*)&ncgtext[2], (char **) 0, 8);
return (BYTE_CONST);
@ -1424,7 +1452,7 @@ YY_RULE_SETUP
YY_BREAK
case 26:
YY_RULE_SETUP
#line 256 "ncgen.l"
#line 258 "ncgen.l"
{
byte_val = (char) strtol((char*)&ncgtext[3], (char **) 0, 16);
return (BYTE_CONST);
@ -1432,7 +1460,7 @@ YY_RULE_SETUP
YY_BREAK
case 27:
YY_RULE_SETUP
#line 260 "ncgen.l"
#line 262 "ncgen.l"
{
switch ((char)ncgtext[2]) {
case 'a': byte_val = '\007'; break; /* not everyone under-
@ -1453,24 +1481,24 @@ YY_RULE_SETUP
YY_BREAK
case 28:
YY_RULE_SETUP
#line 278 "ncgen.l"
#line 280 "ncgen.l"
{ /* whitespace */
break;
}
YY_BREAK
case 29:
YY_RULE_SETUP
#line 281 "ncgen.l"
#line 283 "ncgen.l"
{/* Note: this next rule will not work for UTF8 characters */
return (ncgtext[0]) ;
}
YY_BREAK
case 30:
YY_RULE_SETUP
#line 285 "ncgen.l"
#line 287 "ncgen.l"
ECHO;
YY_BREAK
#line 1474 "lex.ncg.c"
#line 1502 "lex.ncg.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1601,6 +1629,7 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of ncglex */
/* yy_get_next_buffer - try to read in a new buffer
@ -1612,9 +1641,9 @@ case YY_STATE_EOF(INITIAL):
*/
static int yy_get_next_buffer (void)
{
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = (yytext_ptr);
register int number_to_move, i;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
yy_size_t number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@ -1643,7 +1672,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@ -1656,21 +1685,21 @@ static int yy_get_next_buffer (void)
else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -1701,7 +1730,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@ -1725,9 +1754,9 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
if ((int) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ncgrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
@ -1746,14 +1775,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_state_type yy_current_state;
char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1778,10 +1807,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
register int yy_is_jam;
register char *yy_cp = (yy_c_buf_p);
int yy_is_jam;
char *yy_cp = (yy_c_buf_p);
register YY_CHAR yy_c = 1;
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1796,12 +1825,14 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 235);
return yy_is_jam ? 0 : yy_current_state;
return yy_is_jam ? 0 : yy_current_state;
}
static void yyunput (int c, register char * yy_bp )
#ifndef YY_NO_UNPUT
static void yyunput (int c, char * yy_bp )
{
register char *yy_cp;
char *yy_cp;
yy_cp = (yy_c_buf_p);
@ -1811,10 +1842,10 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
yy_size_t number_to_move = (yy_n_chars) + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
@ -1836,6 +1867,8 @@ static int yy_get_next_buffer (void)
(yy_c_buf_p) = yy_cp;
}
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@ -1860,7 +1893,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr);
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -1985,7 +2018,7 @@ static void ncg_load_buffer_state (void)
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in ncg_create_buffer()" );
b->yy_buf_size = size;
b->yy_buf_size = (yy_size_t)size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
@ -2020,10 +2053,6 @@ static void ncg_load_buffer_state (void)
ncgfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a ncgrestart() or at EOF.
@ -2136,7 +2165,7 @@ void ncgpop_buffer_state (void)
*/
static void ncgensure_buffer_stack (void)
{
int num_to_alloc;
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@ -2144,7 +2173,7 @@ static void ncgensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
(yy_buffer_stack) = (struct yy_buffer_state**)ncgalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
@ -2161,7 +2190,7 @@ static void ncgensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)ncgrealloc
@ -2228,17 +2257,17 @@ YY_BUFFER_STATE ncg_scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to ncglex() will
* scan from a @e copy of @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len )
YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@ -2269,7 +2298,7 @@ YY_BUFFER_STATE ncg_scan_bytes (yyconst char * yybytes, int _yybytes_len )
static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@ -2320,7 +2349,7 @@ FILE *ncgget_out (void)
/** Get the length of the current token.
*
*/
int ncgget_leng (void)
yy_size_t ncgget_leng (void)
{
return ncgleng;
}
@ -2335,29 +2364,29 @@ char *ncgget_text (void)
}
/** Set the current line number.
* @param line_number
* @param _line_number line number
*
*/
void ncgset_lineno (int line_number )
void ncgset_lineno (int _line_number )
{
ncglineno = line_number;
ncglineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
* @param _in_str A readable stream.
*
* @see ncg_switch_to_buffer
*/
void ncgset_in (FILE * in_str )
void ncgset_in (FILE * _in_str )
{
ncgin = in_str ;
ncgin = _in_str ;
}
void ncgset_out (FILE * out_str )
void ncgset_out (FILE * _out_str )
{
ncgout = out_str ;
ncgout = _out_str ;
}
int ncgget_debug (void)
@ -2365,9 +2394,9 @@ int ncgget_debug (void)
return ncg_flex_debug;
}
void ncgset_debug (int bdebug )
void ncgset_debug (int _bdebug )
{
ncg_flex_debug = bdebug ;
ncg_flex_debug = _bdebug ;
}
static int yy_init_globals (void)
@ -2427,7 +2456,8 @@ int ncglex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
register int i;
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@ -2436,7 +2466,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
register int n;
int n;
for ( n = 0; s[n]; ++n )
;
@ -2446,11 +2476,12 @@ static int yy_flex_strlen (yyconst char * s )
void *ncgalloc (yy_size_t size )
{
return (void *) malloc( size );
return (void *) malloc( size );
}
void *ncgrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@ -2463,12 +2494,12 @@ void *ncgrealloc (void * ptr, yy_size_t size )
void ncgfree (void * ptr )
{
free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */
free( (char *) ptr ); /* see ncgrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
#line 285 "ncgen.l"
#line 287 "ncgen.l"
@ -2476,8 +2507,9 @@ void ncgfree (void * ptr )
void
ignore()
{
#ifndef YY_NO_UNPUT
yyunput(0,NULL);
#endif
}

View File

@ -5,10 +5,13 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
extern int fileno(FILE*);
#include "ocinternal.h"
#include "ocdebug.h"

View File

@ -28,13 +28,13 @@ SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES OUTPUT_NAME "bzip2")
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES LIBRARY_OUTPUT_NAME "bzip2")
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES ARCHIVE_OUTPUT_NAME "bzip2")
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES RUNTIME_OUTPUT_NAME "bzip2")
TARGET_LINK_LIBRARIES(test_bzip2 ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES})
TARGET_LINK_LIBRARIES(test_bzip2 ${ALL_TLL_LIBS})
ADD_LIBRARY(misc MODULE ${libmisc_SOURCES})
SET_TARGET_PROPERTIES(misc PROPERTIES LIBRARY_OUTPUT_NAME "misc")
SET_TARGET_PROPERTIES(misc PROPERTIES ARCHIVE_OUTPUT_NAME "misc")
SET_TARGET_PROPERTIES(misc PROPERTIES RUNTIME_OUTPUT_NAME "misc")
TARGET_LINK_LIBRARIES(misc ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES})
TARGET_LINK_LIBRARIES(misc ${ALL_TLL_LIBS})
ENDIF(BUILD_UTILITIES)
ENDIF(ENABLE_FILTER_TESTING)