|
NEP 4.3.0
NetCDF Expansion Pack
|
Upstream-compatible provenance attributes for nxCDF. More...
#include "config.h"#include <stdlib.h>#include <string.h>#include "nxcdf_internal.h"#include "nep_meta.h"Macros | |
| #define | NXCDF_NCPROPS "_NCProperties" |
| Upstream's provenance attribute names (nc_provenance.h). | |
| #define | NXCDF_NC3_STRICT "_nc3_strict" |
| #define | NXCDF_ISNETCDF4 "_IsNetcdf4" |
| #define | NXCDF_SUPERBLOCK "_SuperblockVersion" |
Functions | |
| int | nxcdf_build_ncproperties (char **out) |
| Build the _NCProperties value for a new file. | |
| int | nxcdf_read_ncproperties (NXCDF_FILE_INFO_T *file) |
| Read an existing _NCProperties attribute at open. | |
| int | nxcdf_write_provenance (NXCDF_FILE_INFO_T *file) |
| Write _NCProperties and _nc3_strict to a file nxCDF created. | |
| static herr_t | count_marker_atts (hid_t loc, const char *name, const H5O_info_t *info, void *op_data) |
| Count objects carrying NetCDF-4 bookkeeping attributes. | |
| static int | nxcdf_isnetcdf4 (NXCDF_FILE_INFO_T *file) |
| Whether the open file was written by a netCDF-4 library. | |
| int | nxcdf_get_att_special (NXCDF_FILE_INFO_T *file, const char *name, nc_type *xtypep, nc_type mem_type, size_t *lenp, int *attnump, void *data) |
| Answer a name lookup for a provenance attribute. | |
Variables | |
| static const char * | isnetcdf4_markers [] |
| Hidden attribute names that mark an object as NetCDF-4 bookkeeping; two or more anywhere in the file mean "written by
netcdf-4", matching upstream's NC4_isnetcdf4 walk. | |
Upstream-compatible provenance attributes for nxCDF.
Writes the same hidden root-group attributes upstream netcdf-c produces (_NCProperties, _nc3_strict) and answers name lookups for the virtual attributes (_IsNetcdf4, _SuperblockVersion, _NCProperties) that upstream synthesizes in nc4_get_att_special() rather than storing. The stored attributes are deferred to _enddef/nc_sync/nc_close, never overwrite an existing stamp, and are only written for files nxCDF created — a foreign file opened for write keeps whatever provenance it had. See nxCDF Architecture.
| #define NXCDF_ISNETCDF4 "_IsNetcdf4" |
| #define NXCDF_NC3_STRICT "_nc3_strict" |
| #define NXCDF_NCPROPS "_NCProperties" |
Upstream's provenance attribute names (nc_provenance.h).
| #define NXCDF_SUPERBLOCK "_SuperblockVersion" |
|
static |
Count objects carrying NetCDF-4 bookkeeping attributes.
H5Ovisit callback for nxcdf_isnetcdf4(): increments the counter when the visited object has any of the hidden marker attributes — upstream's threshold of two distinguishes a netCDF-4 file from a plain HDF5 file that happens to carry one such name.
| int nxcdf_build_ncproperties | ( | char ** | out | ) |
Build the _NCProperties value for a new file.
Produces version=2,netcdf=<netcdf-c version>,hdf5=<hdf5 version>, nxcdf=<nep version> — upstream's property string plus a nxcdf key, which the version-2 format tolerates. The netcdf-c version is the first token of nc_inq_libvers(); the HDF5 version comes from H5get_libversion; the NEP version is the build-time NEP_VERSION.
| out | Destination for a malloc'd string the caller frees. |
| int nxcdf_get_att_special | ( | NXCDF_FILE_INFO_T * | file, |
| const char * | name, | ||
| nc_type * | xtypep, | ||
| nc_type | mem_type, | ||
| size_t * | lenp, | ||
| int * | attnump, | ||
| void * | data ) |
Answer a name lookup for a provenance attribute.
nxCDF's nc4_get_att_special equivalent: _NCProperties is answered from the in-memory copy (built at create or read at open), while _IsNetcdf4 and _SuperblockVersion are synthesized — they exist only as answers to name lookups, never as stored attributes and never in nc_inq_natts/nc_inq_attname results.
| file | Open nxCDF state. |
| name | Attribute name. |
| xtypep | Optional destination for the file type. |
| mem_type | Requested in-memory type (NC_NAT allowed). |
| lenp | Optional destination for the attribute length. |
| attnump | Non-NULL asks for the attribute's index, which virtual attributes do not have. |
| data | Optional destination for the attribute's value. |
|
static |
Whether the open file was written by a netCDF-4 library.
Mirrors upstream's NC4_isnetcdf4: 1 when _nc3_strict or _NCProperties exists on the root group, else a whole-file walk that requires at least two objects carrying NetCDF-4 marker attributes.
| file | Open nxCDF state. |
| int nxcdf_read_ncproperties | ( | NXCDF_FILE_INFO_T * | file | ) |
Read an existing _NCProperties attribute at open.
Populates file->ncproperties when the root group carries the attribute. A missing or malformed attribute is tolerated — the field stays NULL, matching upstream's "invalid attribute: ignored" leniency.
| file | Open nxCDF state. |
| int nxcdf_write_provenance | ( | NXCDF_FILE_INFO_T * | file | ) |
Write _NCProperties and _nc3_strict to a file nxCDF created.
Called from NXCDF__enddef, NXCDF_sync and NXCDF_close on writable files — the same deferred points upstream's NC4_write_provenance runs. _NCProperties is stored exactly as upstream does: a scalar fixed-length ASCII string of strlen bytes with H5T_STR_NULLTERM padding. _nc3_strict is a scalar H5T_NATIVE_INT = 1 written only for NC_CLASSIC_MODEL files. Neither attribute is ever overwritten, so an existing stamp survives a write-open update. Files nxCDF did not create are never stamped.
| file | Open writable nxCDF state. |
|
static |
Hidden attribute names that mark an object as NetCDF-4 bookkeeping; two or more anywhere in the file mean "written by netcdf-4", matching upstream's NC4_isnetcdf4 walk.