2010-06-03 21:24:43 +08:00
|
|
|
#ifndef NC_NCGEN_H
|
|
|
|
#define NC_NCGEN_H
|
|
|
|
/*********************************************************************
|
2018-12-07 06:40:43 +08:00
|
|
|
* Copyright 2018, UCAR/Unidata
|
2010-06-03 21:24:43 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
|
|
* $Header: /upc/share/CVS/netcdf-3/ncgen/ncgen.h,v 1.18 2010/06/01 15:34:53 ed Exp $
|
2016-05-04 11:17:06 +08:00
|
|
|
*********************************************************************/
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2021-09-05 15:15:36 +08:00
|
|
|
#include "config.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2022-01-25 06:01:23 +08:00
|
|
|
#ifndef nulldup
|
|
|
|
#define nulldup(x) ((x)?strdup(x):(x))
|
|
|
|
#endif
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
#ifdef USE_NETCDF4
|
|
|
|
#define CLASSICONLY 0
|
|
|
|
#else
|
|
|
|
#define CLASSICONLY 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_NC_ATTSIZE 20000 /* max size of attribute (for ncgen) */
|
|
|
|
#define MAXTRST 5000 /* max size of string value (for ncgen) */
|
|
|
|
|
|
|
|
/* Define the possible classes of objects*/
|
|
|
|
/* extend the NC_XXX values*/
|
|
|
|
#define NC_GRP 100
|
|
|
|
#define NC_DIM 101
|
|
|
|
#define NC_VAR 102
|
|
|
|
#define NC_ATT 103
|
|
|
|
#define NC_TYPE 104
|
|
|
|
#define NC_ECONST 105
|
|
|
|
#define NC_FIELD 106
|
|
|
|
#define NC_ARRAY 107
|
|
|
|
#define NC_PRIM 108 /*Including NC_STRING */
|
|
|
|
#define NC_STRUCT NC_COMPOUND /* alias */
|
2012-01-10 02:39:37 +08:00
|
|
|
#define NC_LIST NC_COMPOUND /* alias */
|
2010-06-03 21:24:43 +08:00
|
|
|
|
|
|
|
/* Extend nc types with generic fill value*/
|
2013-07-11 04:00:48 +08:00
|
|
|
#define NC_FILLVALUE 31
|
|
|
|
/* Extend nc types with NIL value*/
|
|
|
|
#define NC_NIL 32
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2012-09-12 04:17:24 +08:00
|
|
|
#define NEGNC_INFINITEF (-NC_INFINITEF)
|
|
|
|
#define NEGNC_INFINITE (-NC_INFINITEF)
|
2017-03-09 08:01:10 +08:00
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
/* nc_class is one of:
|
|
|
|
NC_GRP NC_DIM NC_VAR NC_ATT NC_TYPE
|
|
|
|
*/
|
|
|
|
typedef nc_type nc_class;
|
|
|
|
|
|
|
|
/* nc_subclass is one of:
|
|
|
|
NC_PRIM NC_OPAQUE NC_ENUM
|
|
|
|
NC_FIELD NC_VLEN NC_COMPOUND
|
|
|
|
NC_ECONST NC_ARRAY NC_FILLVALUE
|
|
|
|
*/
|
|
|
|
typedef nc_type nc_subclass;
|
|
|
|
|
|
|
|
/*
|
|
|
|
Define data structure
|
2016-05-04 11:17:06 +08:00
|
|
|
xto hold special attribute values
|
2010-06-03 21:24:43 +08:00
|
|
|
for a given variable.
|
|
|
|
Global values are kept as
|
|
|
|
various C global variables
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Define a bit set for indicating which*/
|
|
|
|
/* specials were explicitly specified*/
|
2016-05-04 11:17:06 +08:00
|
|
|
/* See also: ncgen.y.tag2name */
|
2010-06-03 21:24:43 +08:00
|
|
|
#define _STORAGE_FLAG 0x001
|
|
|
|
#define _CHUNKSIZES_FLAG 0x002
|
|
|
|
#define _FLETCHER32_FLAG 0x004
|
|
|
|
#define _DEFLATE_FLAG 0x008
|
|
|
|
#define _SHUFFLE_FLAG 0x010
|
|
|
|
#define _ENDIAN_FLAG 0x020
|
|
|
|
#define _NOFILL_FLAG 0x040
|
|
|
|
#define _FILLVALUE_FLAG 0x080
|
2016-05-04 11:17:06 +08:00
|
|
|
#define _NCPROPS_FLAG 0x100
|
|
|
|
#define _ISNETCDF4_FLAG 0x200
|
|
|
|
#define _SUPERBLOCK_FLAG 0x400
|
|
|
|
#define _FORMAT_FLAG 0x800
|
2017-05-15 08:10:02 +08:00
|
|
|
#define _FILTER_FLAG 0x1000
|
2021-09-03 07:04:26 +08:00
|
|
|
#define _CODECS_FLAG 0x2000
|
2022-01-29 04:04:16 +08:00
|
|
|
#define _QUANTIZEBG_FLAG 0x4000
|
2022-02-20 08:08:36 +08:00
|
|
|
#define _QUANTIZEGBR_FLAG 0x8000
|
|
|
|
#define _QUANTIZEBR_FLAG 0x10000
|
2016-05-12 05:31:17 +08:00
|
|
|
|
2016-05-04 11:17:06 +08:00
|
|
|
extern struct Specialtoken {
|
|
|
|
char* name;
|
|
|
|
int token;
|
|
|
|
int tag;
|
|
|
|
} specials[];
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2013-09-21 10:31:21 +08:00
|
|
|
/* Define an enumeration of supported languages */
|
|
|
|
typedef enum Language {
|
|
|
|
L_UNDEFINED=0,
|
|
|
|
L_BINARY=1,
|
|
|
|
L_C=2,
|
|
|
|
L_F77=3,
|
|
|
|
L_JAVA=4
|
|
|
|
} Language;
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
struct Kvalues {
|
|
|
|
char* name;
|
2012-02-14 08:25:32 +08:00
|
|
|
int k_flag;
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
int deprecated;
|
2010-06-03 21:24:43 +08:00
|
|
|
};
|
|
|
|
|
2017-04-28 03:01:59 +08:00
|
|
|
extern struct Kvalues legalkinds[];
|
|
|
|
|
|
|
|
#define ZIP_ID 0xFFFFFFFF
|
|
|
|
#define SZIP_ID 0xFFFFFFFE
|
|
|
|
#define BZIP2_ID 307U
|
|
|
|
#define ZFP_ID 32013U
|
|
|
|
#define FPZIP_ID 32014U
|
2010-06-03 21:24:43 +08:00
|
|
|
|
2012-02-14 08:25:32 +08:00
|
|
|
/* Note: some non-var specials (i.e. _Format) are not included in this struct*/
|
2010-06-03 21:24:43 +08:00
|
|
|
typedef struct Specialdata {
|
|
|
|
int flags;
|
2018-11-16 01:00:38 +08:00
|
|
|
Datalist* _Fillvalue; /* This is a per-type ; points to the _FillValue attribute node */
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
int _Storage; /* NC_CHUNKED | NC_CONTIGUOUS | NC_COMPACT*/
|
2010-06-03 21:24:43 +08:00
|
|
|
size_t* _ChunkSizes; /* NULL => defaults*/
|
|
|
|
int nchunks; /* |_Chunksize| ; 0 => not specified*/
|
|
|
|
int _Fletcher32; /* 1=>fletcher32*/
|
|
|
|
int _DeflateLevel; /* 0-9 => level*/
|
|
|
|
int _Shuffle; /* 0 => false, 1 => true*/
|
|
|
|
int _Endianness; /* 1 =>little, 2 => big*/
|
|
|
|
int _Fill ; /* 0 => false, 1 => true WATCHOUT: this is inverse of NOFILL*/
|
2022-01-25 06:22:24 +08:00
|
|
|
int _Quantizer; /* algorithm */
|
|
|
|
int _NSD; /* No. of significant digits */
|
2020-09-28 02:43:46 +08:00
|
|
|
NC_H5_Filterspec** _Filters;
|
|
|
|
size_t nfilters; /* |filters| */
|
2021-09-03 07:04:26 +08:00
|
|
|
char* _Codecs; /* in JSON form */
|
2010-06-03 21:24:43 +08:00
|
|
|
} Specialdata;
|
|
|
|
|
2016-05-04 11:17:06 +08:00
|
|
|
typedef struct GlobalSpecialdata {
|
|
|
|
int _Format ; /* kflag */
|
2016-05-12 05:31:17 +08:00
|
|
|
const char* _NCProperties ;
|
2016-05-04 11:17:06 +08:00
|
|
|
int _IsNetcdf4 ; /* 0 => false, 1 => true */
|
|
|
|
int _Superblock ; /* HDF5 file superblock version */
|
|
|
|
} GlobalSpecialData;
|
|
|
|
|
2018-11-16 01:00:38 +08:00
|
|
|
/*
|
|
|
|
During the generation of binary data,
|
|
|
|
we will generate a number of references
|
|
|
|
to strings and opaques that should
|
|
|
|
be reclaimed to keep the memory
|
|
|
|
checkers happy.
|
|
|
|
*/
|
|
|
|
typedef struct BinBuffer {
|
|
|
|
Bytebuffer* buf; /* top level data */
|
|
|
|
List* reclaim; /* objects that need to be free'd */
|
|
|
|
} BinBuffer;
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
/* Track a set of dimensions*/
|
|
|
|
/* (Note: the netcdf type system is deficient here)*/
|
|
|
|
typedef struct Dimset {
|
|
|
|
int ndims;
|
|
|
|
struct Symbol* dimsyms[NC_MAX_VAR_DIMS]; /* Symbol for dimension*/
|
|
|
|
} Dimset;
|
|
|
|
|
|
|
|
typedef struct Diminfo {
|
|
|
|
int isconstant; /* separate constant from named dimension*/
|
2012-02-14 08:25:32 +08:00
|
|
|
int isunlimited;
|
2010-06-03 21:24:43 +08:00
|
|
|
size_t declsize; /* 0 => unlimited/unspecified*/
|
|
|
|
} Diminfo;
|
|
|
|
|
|
|
|
typedef struct Attrinfo {
|
|
|
|
struct Symbol* var; /* NULL => global*/
|
|
|
|
} Attrinfo;
|
|
|
|
|
|
|
|
typedef struct Typeinfo {
|
|
|
|
struct Symbol* basetype;
|
|
|
|
int hasvlen; /* 1 => this type contains a vlen*/
|
|
|
|
nc_type typecode;
|
|
|
|
unsigned long offset; /* fields in struct*/
|
|
|
|
unsigned long alignment;/* fields in struct*/
|
2019-04-20 10:32:26 +08:00
|
|
|
NCConstant* econst; /* for enum values*/
|
2010-06-03 21:24:43 +08:00
|
|
|
Dimset dimset; /* for NC_VAR/NC_FIELD/NC_ATT*/
|
|
|
|
size_t size; /* for opaque, compound, etc.*/
|
2016-11-18 06:29:32 +08:00
|
|
|
size_t cmpdalign; /* alignment needed for total size instances */
|
2010-06-03 21:24:43 +08:00
|
|
|
size_t nelems; /* size in terms of # of datalist constants
|
|
|
|
it takes to represent it */
|
2012-02-14 08:25:32 +08:00
|
|
|
Datalist* _Fillvalue; /* per-type cached fillvalue
|
|
|
|
(overridden by var fillvalue) */
|
2010-06-03 21:24:43 +08:00
|
|
|
} Typeinfo;
|
|
|
|
|
|
|
|
typedef struct Varinfo {
|
|
|
|
int nattributes; /* |attributes|*/
|
|
|
|
List* attributes; /* List<Symbol*>*/
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
Specialdata special;
|
2010-06-03 21:24:43 +08:00
|
|
|
} Varinfo;
|
|
|
|
|
|
|
|
typedef struct Groupinfo {
|
|
|
|
int is_root;
|
|
|
|
} Groupinfo;
|
|
|
|
|
2018-11-16 01:00:38 +08:00
|
|
|
typedef struct Fileinfo {
|
|
|
|
char* filename;
|
|
|
|
} Fileinfo;
|
|
|
|
|
2013-09-21 10:31:21 +08:00
|
|
|
/* store info when the symbol
|
|
|
|
is really a reference to another
|
|
|
|
symbol
|
|
|
|
*/
|
|
|
|
typedef struct Reference {
|
|
|
|
int is_ref; /* separate name defs from refs*/
|
|
|
|
char* unescaped; /* original, unescaped name */
|
|
|
|
struct Symbol* ref; /* ptr to the symbol if is_ref is true*/
|
|
|
|
} Reference;
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
typedef struct Symbol { /* symbol table entry*/
|
|
|
|
nc_class objectclass; /* NC_DIM|NC_VLEN|NC_OPAQUE...*/
|
|
|
|
nc_class subclass; /* NC_STRUCT|...*/
|
|
|
|
char* name;
|
2013-09-21 10:31:21 +08:00
|
|
|
char* fqn; /* cached fully qualified C or FORTRAN name*/
|
2010-06-03 21:24:43 +08:00
|
|
|
struct Symbol* container; /* The group containing this symbol.*/
|
|
|
|
/* for fields or enumids, it is*/
|
|
|
|
/* the parent type.*/
|
|
|
|
struct Symbol* location; /* current group when symbol was created*/
|
|
|
|
List* subnodes; /* sublist for enum or struct or group*/
|
|
|
|
int is_prefixed; /* prefix was specified (vs computed).*/
|
|
|
|
List* prefix; /* List<Symbol*>*/
|
|
|
|
struct Datalist* data; /* shared by variables and attributes*/
|
|
|
|
/* Note that we cannot union these because some kinds of symbols*/
|
|
|
|
/* use more than one part*/
|
|
|
|
Typeinfo typ; /* type info for e.g. var, att, etc.*/
|
|
|
|
Varinfo var;
|
2016-05-12 05:31:17 +08:00
|
|
|
Attrinfo att;
|
2010-06-03 21:24:43 +08:00
|
|
|
Diminfo dim;
|
|
|
|
Groupinfo grp;
|
2018-11-16 01:00:38 +08:00
|
|
|
Fileinfo file;
|
2018-03-16 22:38:40 +08:00
|
|
|
Reference ref; /* symbol is really a reference to another symbol*/
|
2010-06-03 21:24:43 +08:00
|
|
|
/* Misc pieces of info*/
|
|
|
|
int lineno; /* at point of creation*/
|
|
|
|
int touched; /* for sorting*/
|
2018-11-16 01:00:38 +08:00
|
|
|
/* for use by -lb */
|
|
|
|
int nc_id; /* from netcdf API: varid, or dimid, or etc.*/
|
2010-06-03 21:24:43 +08:00
|
|
|
} Symbol;
|
|
|
|
|
|
|
|
|
|
|
|
#endif /*!NC_NCGEN_H*/
|