|
NEP 4.3.0
NetCDF Expansion Pack
|
nxCDF metadata model: dimensions, variables, attributes, type mapping, and on-disk discovery. More...
#include "nxcdf/nxcdf.h"#include "config.h"#include <stdlib.h>#include <string.h>#include <assert.h>#include <math.h>#include <hdf5_hl.h>#include "nclist.h"#include "nxcdf_internal.h"Data Structures | |
| struct | dim_list_t |
| Accumulator used while iterating a group's links looking for dimension scales. More... | |
| struct | var_list_t |
| Accumulator used while iterating a group's links looking for variable datasets — the varid counterpart of dim_list_t. More... | |
| struct | resolve_scale_t |
| Context for scale_resolve_visitor(): group to search, result dimid slot, and a done flag. More... | |
| struct | att_iter_data_t |
| Context for load_att_cb(): the attribute index to fill, the owning object, and the HDF5 location to iterate. More... | |
| struct | load_children_data_t |
| Context carried to load_children_cb(): file state, parent group record, and parent HDF5 handle. More... | |
Functions | |
| static int | nxcdf_set_att_order (hid_t ocpl) |
| Attribute names that are internal to nxCDF/HDF5. | |
| static int | nxcdf_dcpl_fill (hid_t dcpl, NC_FILE_INFO_T *h5, NC_VAR_INFO_T *var, hid_t hdf_type) |
| Write the variable's fill setting to a dataset creation property list. | |
| static int | nxcdf_rewrite_atts (hid_t loc, NCindex *list, NC_GRP_INFO_T *grp) |
| Rewrite every attribute on an HDF5 object in index order. | |
| static int | nxcdf_reattach_dim (NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, hid_t old_dset, hid_t new_dset, NC_VAR_INFO_T *skip) |
| Reattach every variable on a dimension from one scale dataset to another. | |
| static int | nxcdf_write_quantize_att (hid_t dataset, const NC_VAR_INFO_T *var) |
| Persist a variable's quantize setting as the upstream _Quantize* attribute. | |
| static int | nxcdf_var_dapl (const NC_VAR_INFO_T *var, hid_t *daplp) |
| Build an owned access-property list from a variable's session settings. | |
| static int | nxcdf_cache_aliases (NC_GRP_INFO_T *grp, hid_t target, const H5O_token_t *token, NClist *slots) |
| Collect owned dataset-handle slots aliasing one HDF5 object. All aliases must close before opening with a different DAPL; otherwise HDF5 retains the first open's raw-data cache even for newly opened handles. | |
| static int | nxcdf_reopen_var_cache (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var) |
| Reopen every owned alias of a variable with its requested cache. Object identity and metadata stay unchanged. If reopening fails, restore the previous DAPL where possible; a failed recovery leaves invalid, not stale, handles and returns an HDF5 error. | |
| int | NXCDF_set_var_chunk_cache (int ncid, int varid, size_t size, size_t nelems, float preemption) |
| Apply session-only cache settings without recreating dataset storage. Read-only and data-mode calls are permitted. Pending datasets retain the request until creation; live datasets reopen all owned aliases together. | |
| int | NXCDF_get_var_chunk_cache (int ncid, int varid, size_t *sizep, size_t *nelemsp, float *preemptionp) |
| Inquire effective chunk cache properties, allowing NULL outputs. A pending or nonchunked variable reports its stored session request. Live chunked variables report the DAPL actually attached to the dataset handle. | |
| static void | nxcdf_dim_wo_var_name (const NC_DIM_INFO_T *dim, char *namebuf, size_t buflen) |
| Build the scale NAME for a dimension without a variable. | |
| static int | is_reserved_att (const char *name) |
| Test whether an attribute name is reserved for internal use. | |
| static void | free_name_list (char **names, size_t n) |
| Free a dynamically-allocated string list used by the loader. | |
| int | NXCDF_check_write_define (NC_FILE_INFO_T *h5, NXCDF_FILE_INFO_T *file) |
| Check that a file is writable and currently in define mode. | |
| int | NXCDF_map_hdf_type (nc_type xtype, hid_t *typep) |
| Map an atomic nc_type to its on-disk HDF5 datatype. | |
| int | NXCDF_type_size (nc_type xtype, size_t *sizep) |
| Return the in-memory size, in bytes, of an atomic nc_type. | |
| const char * | NXCDF_type_name (nc_type xtype) |
| Return the short name for an atomic nc_type. | |
| int | NXCDF_check_atomic_type (NXCDF_FILE_INFO_T *file, nc_type xtype) |
| Check whether an atomic type is allowed for the file's compatibility mode. | |
| static int | set_var_type (NC_VAR_INFO_T *var, nc_type xtype) |
| Build the NC_TYPE_INFO_T record for an atomic-typed variable. | |
| static int | write_string_att (hid_t loc, const char *name, const char *value) |
| Write a null-terminated scalar string HDF5 attribute. | |
| static int | write_int_att (hid_t loc, const char *name, int value) |
| Write a one-element 32-bit integer HDF5 attribute. | |
| static int | write_int_array_att (hid_t loc, const char *name, const int *values, size_t len) |
| Write an array of 32-bit integers as an HDF5 attribute. | |
| static int | map_nc_type (hid_t htype, nc_type *xtypep) |
| Map an on-disk HDF5 datatype back to a NetCDF atomic type. | |
| static int | get_att_context (NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NCindex **listp, hid_t *locp) |
| Resolve where an attribute lives: on a variable's dataset or on the root group. | |
| static int | nxcdf_att_list_del (NCindex *list, NC_ATT_INFO_T *att) |
| Delete an attribute from an index and free it. | |
| static NC_ATT_INFO_T * | find_att (NCindex *list, const char *name) |
| Find an existing attribute by name in an attribute index. | |
| static int | nxcdf_type_varsized (NC_GRP_INFO_T *grp, nc_type xtype, int *vsp) |
| Report whether a type is (transitively) variable-sized. | |
| static int | add_att (NCindex *list, NC_OBJ *container, NC_GRP_INFO_T *grp, const char *name, nc_type xtype, size_t len, const void *data, NC_ATT_INFO_T **attp) |
| Allocate and add a new attribute to the in-memory model. | |
| static int | read_hdf5_att (hid_t loc, const char *name, NCindex *list, NC_OBJ *container, NC_GRP_INFO_T *grp) |
| Read one HDF5 attribute into the in-memory model. | |
| int | NXCDF_def_dim (int ncid, const char *name, size_t len, int *idp) |
| Define a dimension — the nc_def_dim() dispatch entry. | |
| int | NXCDF_inq_dim (int ncid, int dimid, char *name, size_t *lenp) |
| Inquire about a dimension — the nc_inq_dim() dispatch entry. | |
| int | NXCDF_def_var (int ncid, const char *name, nc_type xtype, int ndims, const int *dimidsp, int *varidp) |
| Define a variable — the nc_def_var() dispatch entry. | |
| int | nxcdf_create_var_dataset (NC_VAR_INFO_T *var, NC_FILE_INFO_T *h5, NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp) |
| Create or re-create the HDF5 dataset for a variable. | |
| int | nxcdf_find_var_for_write (int ncid, int varid, NC_FILE_INFO_T **h5, NXCDF_FILE_INFO_T **file, NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var) |
| Common prologue for the def-var setter dispatch functions. | |
| int | NXCDF_def_var_chunking (int ncid, int varid, int storage, const size_t *chunksizesp) |
| Set storage and chunk sizes — the nc_def_var_chunking() dispatch entry. | |
| int | NXCDF_def_var_fill (int ncid, int varid, int no_fill, const void *fill_value) |
| Set fill behavior — the nc_def_var_fill() dispatch entry. | |
| int | NXCDF_def_var_endian (int ncid, int varid, int endianness) |
| Set the on-disk byte order — the nc_def_var_endian() dispatch entry. | |
| int | NXCDF_def_var_quantize (int ncid, int varid, int quantize_mode, int nsd) |
| Set quantization — the nc_def_var_quantize() dispatch entry. | |
| int | NXCDF_inq_var_all (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp, int *shufflep, int *deflatep, int *deflate_levelp, int *fletcher32p, int *contiguousp, size_t *chunksizesp, int *no_fillp, void *fill_valuep, int *endiannessp, unsigned int *idp, size_t *nparamsp, unsigned int *params) |
| Inquire about all supported properties of a variable — the nc_inq_var_all() dispatch entry. | |
| int | NXCDF_inq_var (int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp, int *dimidsp, int *nattsp) |
| Inquire about a variable's name, type, dimensions, and attributes — the nc_inq_var() dispatch entry. | |
| static int | nxcdf_write_att (hid_t loc, const NC_ATT_INFO_T *att, NC_GRP_INFO_T *grp) |
| Write one in-memory attribute to an HDF5 object. | |
| int | nxcdf_flush_pending_atts (NC_GRP_INFO_T *grp) |
| Materialize attributes deferred while their datatype or dataset was pending — called at _enddef. | |
| int | NXCDF_put_att (int ncid, int varid, const char *name, nc_type datatype, size_t len, const void *value, nc_type memtype) |
| Create or replace an attribute — the nc_put_att_* dispatch entry. | |
| int | NXCDF_inq_att (int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp) |
| Inquire about an attribute — the nc_inq_att() dispatch entry. | |
| int | NXCDF_inq_attid (int ncid, int varid, const char *name, int *attnump) |
| Learn an attribute's index by name — the nc_inq_attid() dispatch entry. | |
| int | NXCDF_get_att (int ncid, int varid, const char *name, void *value, nc_type memtype) |
| Read an attribute's value — the nc_get_att_* dispatch entry. | |
| int | NXCDF_rename_att (int ncid, int varid, const char *name, const char *newname) |
| Rename an attribute — the nc_rename_att() dispatch entry. | |
| static int | nxcdf_dimscale_create (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, const char *name, hid_t *dsetp) |
| Create a standalone dimension-scale dataset for a dimension. | |
| static int | nxcdf_break_coord_var (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *cvar, const char *scalename) |
| Break a coordinate-variable relationship. | |
| static int | nxcdf_reform_coord_var (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var) |
| Reform a coordinate-variable relationship. | |
| static NC_VAR_INFO_T * | find_coord_var (NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim) |
| static NC_DIM_INFO_T * | coord_var_dim (NC_VAR_INFO_T *var) |
| int | NXCDF_rename_dim (int ncid, int dimid, const char *name) |
| Rename a dimension and update its HDF5 link. | |
| int | NXCDF_rename_var (int ncid, int varid, const char *name) |
| Rename a variable and update its HDF5 link. | |
| int | NXCDF_del_att (int ncid, int varid, const char *name) |
| Delete an attribute from a group or variable. | |
| static herr_t | find_dim_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data) |
| H5Literate callback collecting dimension-scale datasets. | |
| static int | load_one_dim (NXCDF_FILE_INFO_T *file, NC_GRP_INFO_T *grp, const char *name, int dimid) |
| Load one dimension from its scale dataset into the in-memory tree. | |
| static int | load_dimensions (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp) |
| Load all of a group's dimensions in stable dimid order. | |
| static herr_t | find_var_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data) |
| H5Literate callback collecting candidate variable datasets. | |
| static NC_DIM_INFO_T * | find_dim_by_name (NC_GRP_INFO_T *grp, const char *name) |
| Find a dimension by name in a group or any ancestor. | |
| static int | scale_resolve_visitor (hid_t did, unsigned int dim, hid_t dsid, void *op_data) |
| H5DSiterate_scales visitor resolving one attached scale to a dimid. | |
| static int | resolve_var_dimids (NC_GRP_INFO_T *grp, hid_t dset, int ndims, int *dimids) |
| Resolve a variable's dimids from its attached dimension scales. | |
| static int | load_one_var (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, const char *name, int varid) |
| Load one variable dataset into the in-memory tree. | |
| static H5_index_t | att_iter_index (hid_t obj, int group) |
| Pick the H5Aiterate2 index that preserves attribute creation order when the object tracks it. | |
| static herr_t | load_att_cb (hid_t loc, const char *attr_name, const H5A_info_t *ainfo, void *op_data) |
| H5Aiterate2 callback loading a single user attribute. | |
| static int | nxcdf_fill_from_att (NC_VAR_INFO_T *var) |
| Mirror a loaded _FillValue attribute into var->fill_value. | |
| static int | nxcdf_quantize_from_att (NC_VAR_INFO_T *var) |
| Restore a variable's quantize setting from its _Quantize* attribute. | |
| static int | load_variables (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp) |
| Load all of a group's variables and their attributes. | |
| static int | load_group_attributes (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp) |
| Load a group's own (non-global) attributes. | |
| static int | load_children (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, hid_t parent_hdf, NC_GRP_INFO_T *parent) |
| Iterate a group's links loading child groups and committed types. | |
| static int | load_one_type (NC_GRP_INFO_T *grp, hid_t htype, const char *name) |
| Load one committed HDF5 datatype into the in-memory type list. | |
| static int | load_types (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp) |
| Register every committed datatype in a group. | |
| static int | load_type_members (NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type) |
| Fill the members of a registered type record from its HDF5 datatype. | |
| static int | load_group_metadata (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *grp, hid_t hdf_grp) |
| Load one group's full metadata: dimensions, committed types, variables, attributes, then children recursively. | |
| static int | load_one_group (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5, NC_GRP_INFO_T *parent, hid_t parent_hdf, const char *name) |
| Open one child HDF5 group and load it recursively. | |
| static herr_t | load_type_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data) |
| H5Literate callback loading one committed datatype. | |
| static herr_t | load_children_cb (hid_t loc, const char *name, const H5L_info_t *info, void *op_data) |
| H5Literate callback dispatching each child link to the right loader. | |
| int | NXCDF_load_metadata (NXCDF_FILE_INFO_T *file, NC_FILE_INFO_T *h5) |
| Load all metadata for an open nxCDF file — the entry point NXCDF_open() calls after checking the marker attributes. | |
Variables | |
| static const char * | reserved_atts [] |
nxCDF metadata model: dimensions, variables, attributes, type mapping, and on-disk discovery.
This file contains the two halves of the metadata lifecycle (see nxCDF Architecture): the def/inq dispatch entries that build and query the in-memory NC_*_INFO_T tree during define mode, and the loader (NXCDF_load_metadata and its helpers) that rebuilds the same tree from HDF5 contents at open.
|
static |
Allocate and add a new attribute to the in-memory model.
Deep-copies the attribute value: numeric data by memcpy, NC_STRING values element-by-element (NULL elements become empty strings), and variable-sized user types (vlens and compounds containing them) recursively through NEP's reclaim-safe nxcdf_copy_data() — so the attribute record owns its data outright and the caller may mutate or free the input immediately.
| list | Attribute index to add to. |
| container | Object that owns the attribute (group or var hdr). |
| grp | Group used to resolve user-defined type sizes. |
| name | Name. |
| xtype | NetCDF atomic or user-defined type. |
| len | Number of elements. |
| data | Data buffer. |
| attp | Destination for the new attribute. |
|
static |
Pick the H5Aiterate2 index that preserves attribute creation order when the object tracks it.
nxCDF and upstream files record H5P_CRT_ORDER_TRACKED on every group and dataset; plain HDF5 objects without tracking fall back to name order.
| obj | HDF5 dataset or group identifier. |
| group | Nonzero when obj is a group, zero for a dataset. |
|
static |
Determine if a variable is a 1D coordinate variable.
| var | Variable. |
|
static |
Find an existing attribute by name in an attribute index.
| list | Attribute index to search. |
| name | Name. |
|
static |
Find a 1D coordinate variable that uses a dimension.
| grp | Group. |
| dim | Dimension. |
|
static |
Find a dimension by name in a group or any ancestor.
Dimension scope in netCDF flows downward — a variable may use any ancestor's dimensions, never a sibling's.
| grp | Group. |
| name | Name. |
|
static |
H5Literate callback collecting dimension-scale datasets.
A link is a dimension scale when its dataset carries CLASS = "DIMENSION_SCALE" and a _Netcdf4Dimid attribute; those two hidden attributes are how the loader recovers both the name and the dimid. Anything else is skipped.
| loc | HDF5 location identifier. |
| name | Name. |
| info | Link info (unused). |
| op_data | dim_list_t collection context. |
|
static |
H5Literate callback collecting candidate variable datasets.
Datasets carrying _Netcdf4Varid are variables unconditionally. Without it (files written by upstream netcdf-c or older nxCDF), heuristics apply: dimension scales count only if they are coordinate variables (carry _Netcdf4Coordinates), and plain datasets count only if they have attached scales or the coordinates attribute — this is what lets the loader read unmarked netCDF-4/HDF5 files.
| loc | HDF5 location identifier. |
| name | Name. |
| info | Link info (unused). |
| op_data | var_list_t collection context. |
|
static |
Free a dynamically-allocated string list used by the loader.
The H5Literate callbacks (find_dim_cb, find_var_cb) build NULL-terminated-capacity arrays of strdup'd names; this frees the elements and the array.
| names | String array. |
| n | Element count. |
|
static |
Resolve where an attribute lives: on a variable's dataset or on the root group.
netCDF attributes are either per-variable or global (NC_GLOBAL, which nxCDF stores on the root group). Returns both the in-memory NCindex and the HDF5 hid_t the attribute is written to.
| grp | Group. |
| var | Variable, or NULL for a group (global) attribute. |
| listp | Destination for the attribute index. |
| locp | Destination for the HDF5 location identifier — a negative value when the variable's dataset has not been created yet (user-defined types defer it to _enddef), in which case the caller must skip HDF5 writes and mark the attributes pending. |
|
static |
Test whether an attribute name is reserved for internal use.
See reserved_atts. Used to hide nxCDF bookkeeping attributes from users and to reject reserved names in nc_put_att.
| name | Name. |
name is a reserved attribute name.
|
static |
H5Aiterate2 callback loading a single user attribute.
Reserved (internal) attributes and attributes whose datatype doesn't map to an atomic nc_type are skipped — neither should make an otherwise-valid file unopenable. _FillValue on a variable is the one exception: upstream exposes it as a normal, user-visible attribute (#377).
| loc | HDF5 location identifier. |
| attr_name | HDF5 attribute name. |
| ainfo | Attribute info (unused). |
| op_data | att_iter_data_t iteration context. |
|
static |
Iterate a group's links loading child groups and committed types.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| parent_hdf | Parent HDF5 group identifier. |
| parent | Parent group. |
|
static |
H5Literate callback dispatching each child link to the right loader.
Links that open as groups become subgroups (load_one_group); committed datatypes were already registered by the load_types() pass and datasets by the variable pass. Anything else is skipped.
| loc | HDF5 location identifier. |
| name | Name. |
| info | Link info (unused). |
| op_data | load_children_data_t iteration context. |
|
static |
Load all of a group's dimensions in stable dimid order.
HDF5 iterates links by name, but netCDF dimids are positional — so the callback pass collects them and this replays them 0..maxid. Missing ids (a sparse id space) fail as NC_EFILEMETA.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
|
static |
Load a group's own (non-global) attributes.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
|
static |
Load one group's full metadata: dimensions, committed types, variables, attributes, then children recursively.
Order matters — dimensions and committed types must exist before variables resolve their dimids and datatypes, and children load last so their parent's types are visible to them. An unmarked root group with nothing loadable is rejected (NC_ENOTNC): a plain HDF5 file with no netCDF structure is not a netCDF file.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
| hdf_grp | HDF5 group identifier. |
|
static |
Load one dimension from its scale dataset into the in-memory tree.
Recovers current length and unlimited-ness (H5S_UNLIMITED max extent) from the dataset's dataspace, keeps the dataset hid_t open in NXCDF_DIM_INFO_T for later scale attachment.
| file | nxCDF file state. |
| grp | Group. |
| name | Name. |
| dimid | Dimension identifier. |
|
static |
Open one child HDF5 group and load it recursively.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| parent | Parent group. |
| parent_hdf | Parent HDF5 group identifier. |
| name | Name. |
|
static |
Load one committed HDF5 datatype into the in-memory type list.
Committed datatypes are the on-disk form of user-defined types. The HDF5 class sets the nc_type_class; enum and vlen base types are recovered from the datatype's super-type. The hid_t is kept open in NXCDF_TYPE_INFO_T.
| grp | Group. |
| htype | HDF5 committed datatype (ownership transferred on success). |
| name | Name. |
|
static |
Load one variable dataset into the in-memory tree.
Rebuilds the full NC_VAR_INFO_T: type via map_nc_type(), rank and dims from the dataspace, dimids from _Netcdf4Coordinates (or attached scales), then — from the dataset creation property list — chunking/storage, fill behavior and value, the filter pipeline (deflate/shuffle/fletcher32), and endianness from the datatype's byte order. meta_read/atts_read/created are set so netcdf-c treats the variable as fully loaded, not new.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
| name | Name. |
| varid | Variable identifier (currently unused; ids come from load order). |
|
static |
H5Literate callback loading one committed datatype.
Committed datatypes are the on-disk form of user-defined types. They must all be registered — and their members populated — before any variable or attribute that references them is loaded, so this pass runs ahead of load_variables()/load_group_attributes().
| loc | HDF5 location identifier. |
| name | Name. |
| info | Link info (unused). |
| op_data | load_children_data_t iteration context. |
|
static |
Fill the members of a registered type record from its HDF5 datatype.
Second pass of load_types(): runs once every committed datatype in the group has a registered record, so compound member types and vlen bases resolve through nxcdf_hdf_type_match() regardless of the order HDF5 links were iterated. Array members recover their rank and shape via H5Tget_array_ndims()/H5Tget_array_dims().
| grp | Group. |
| type | Type record with format_type_info populated. |
|
static |
Register every committed datatype in a group.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
|
static |
Load all of a group's variables and their attributes.
Collects candidates with find_var_cb(), then loads in stored-varid order when _Netcdf4Varid attributes exist (preserving the ids assigned at create), else in HDF5 iteration order. Each variable's user attributes are iterated with H5Aiterate2.
| file | nxCDF file state. |
| h5 | NetCDF-4 file state. |
| grp | Group. |
|
static |
Map an on-disk HDF5 datatype back to a NetCDF atomic type.
Inverse of NXCDF_map_hdf_type(), used at open. HDF5 class + size + sign resolves the standard types; small floats, references and complex need H5Tequal against specific predefined types. Datatypes that don't map (e.g. committed user types, which are loaded by load_one_type instead) yield NC_EBADTYPE.
| htype | HDF5 datatype to map. |
| xtypep | Destination for the NetCDF atomic type. |
|
static |
Delete an attribute from an index and free it.
nc4_att_list_del() deletes by att->hdr.id, but ids drift out of sync with list positions after earlier deletes: mid-list removal does not rehash the name map or renumber the survivors, so a later delete can drop the wrong attribute and ncindexlookup() returns stale positions. Find the real slot, delete it, renumber, rebuild the name map, then free the record.
| list | Attribute index. |
| att | Attribute to delete. |
|
static |
Break a coordinate-variable relationship.
Upstream nc4_break_coord_var() semantics: the shared dataset stays with the variable under its link name, the dimension gets a standalone scale dataset under scalename, all other variables are reattached to it, and the variable's dataset loses all its dimscale markers (_Netcdf4Dimid, CLASS, NAME) so neither the loader nor upstream readers recover a phantom dimension (#398).
| file | nxCDF file state. |
| grp | Group containing the dimension. |
| dim | Dimension leaving the relationship. |
| cvar | Former coordinate variable. |
| scalename | Name for the dimension's new scale dataset. |
|
static |
Collect owned dataset-handle slots aliasing one HDF5 object. All aliases must close before opening with a different DAPL; otherwise HDF5 retains the first open's raw-data cache even for newly opened handles.
| grp | Subtree to search for variable and dimension-scale handles. |
| target | Open dataset used as the object-token comparison location. |
| token | Target object token. |
| slots | List of pointers to owned handle slots, not handles to close yet. |
| int NXCDF_check_atomic_type | ( | NXCDF_FILE_INFO_T * | file, |
| nc_type | xtype ) |
Check whether an atomic type is allowed for the file's compatibility mode.
Called at nc_def_var/nc_put_att time. NC_CLASSIC_MODEL files accept only the six classic types; NC_NETCDF4_MODEL adds the enhanced types (unsigned ints, int64, string) but not the nxCDF-only types (small floats, complex, bitfields, references), keeping the file readable by upstream netcdf-c. See the mode table in nxCDF Architecture.
| file | nxCDF file state. |
| xtype | Candidate NetCDF type. |
| int NXCDF_check_write_define | ( | NC_FILE_INFO_T * | h5, |
| NXCDF_FILE_INFO_T * | file ) |
Check that a file is writable and currently in define mode.
Common guard for every metadata-changing dispatch entry (nc_def_*, nc_rename_*, nc_put_att, nc_del_att). netCDF semantics require define mode for metadata changes; files opened read-only reject them outright. A metadata call in data mode silently re-enters define mode, as upstream NC4_redef does; classic-model files keep the strict NC_ENOTINDEFINE rule.
| h5 | NetCDF-4 file state (may be NULL). |
| file | nxCDF file state. |
| int nxcdf_create_var_dataset | ( | NC_VAR_INFO_T * | var, |
| NC_FILE_INFO_T * | h5, | ||
| NXCDF_FILE_INFO_T * | file, | ||
| NC_GRP_INFO_T * | grp ) |
Create or re-create the HDF5 dataset for a variable.
Called by NXCDF_def_var and from NXCDF__enddef for every variable a def-var setter marked dcpl_dirty: because HDF5 dataset creation properties are immutable, changing chunking/compression/fill/endian requires deleting the dataset link and recreating it with a new creation property list. Recreation detaches the dimension-scale references that point at the old object, rewrites the hidden id attributes and the variable's scale attachments, re-attaches a coordinate variable's dependents to the new scale, and restores the user attributes the delete dropped. The variable's filter pipeline comes from var->filters via nxcdf_apply_filters().
| var | Variable. |
| h5 | NetCDF-4 file state. |
| file | nxCDF file state. |
| grp | Group. |
|
static |
Write the variable's fill setting to a dataset creation property list.
Mirrors upstream: no_fill disables fill entirely; otherwise the user's fill value or the type default is written, so unwritten elements read back NC_FILL_* instead of HDF5's zero default.
| dcpl | Dataset creation property list. |
| h5 | NetCDF-4 file state. |
| var | Variable. |
| hdf_type | Dataset HDF5 datatype. |
| int NXCDF_def_dim | ( | int | ncid, |
| const char * | name, | ||
| size_t | len, | ||
| int * | idp ) |
Define a dimension — the nc_def_dim() dispatch entry.
nxCDF stores each dimension as an HDF5 dimension scale: a 1-D int8 dataset marked CLASS = "DIMENSION_SCALE" with hidden NAME and _Netcdf4Dimid attributes. An unlimited dimension (len == 0) becomes a chunked dataset with H5S_UNLIMITED extent. Classic-model files get at most one unlimited dimension.
| ncid | NetCDF file identifier. |
| name | Dimension name. |
| len | Dimension length, or 0 for unlimited. |
| idp | Destination for the assigned dimension id. |
| int NXCDF_def_var | ( | int | ncid, |
| const char * | name, | ||
| nc_type | xtype, | ||
| int | ndims, | ||
| const int * | dimidsp, | ||
| int * | varidp ) |
Define a variable — the nc_def_var() dispatch entry.
Builds the NC_VAR_INFO_T record and creates the HDF5 dataset immediately: scalar variables get a scalar dataspace, dimensioned variables a simple dataspace (unlimited dims force chunked layout). The hidden _Netcdf4Varid and _Netcdf4Coordinates attributes are written on the dataset, and each dimension's scale is attached with H5DSattach_scale. A 1-D variable named after its only dimension is a coordinate variable — it replaces the dimension's scale dataset so the variable's data is the scale.
var->storage starts at -1 ("not specified") so that layout is decided here and a later def-var setter cannot silently change it (issue #382).
| ncid | NetCDF file identifier. |
| name | Variable name. |
| xtype | NetCDF atomic type. |
| ndims | Number of dimensions. |
| dimidsp | Array of dimension ids. |
| varidp | Destination for the assigned variable id. |
| int NXCDF_def_var_chunking | ( | int | ncid, |
| int | varid, | ||
| int | storage, | ||
| const size_t * | chunksizesp ) |
Set storage and chunk sizes — the nc_def_var_chunking() dispatch entry.
Records the layout and per-dimension chunk sizes and marks the variable dcpl_dirty; layout is fixed at dataset creation in HDF5, so _enddef rebuilds the dataset once with the new creation properties.
| ncid | NetCDF file identifier. |
| varid | Variable identifier. |
| storage | Storage class (NC_CHUNKED or NC_CONTIGUOUS; NC_COMPACT is rejected). |
| chunksizesp | Chunk size for each dimension, or NULL. |
| int NXCDF_def_var_endian | ( | int | ncid, |
| int | varid, | ||
| int | endianness ) |
Set the on-disk byte order — the nc_def_var_endian() dispatch entry.
Records the byte order on the variable and marks it dcpl_dirty; the _enddef rebuild applies it to the dataset's datatype. NC_ENDIAN_NATIVE leaves the little-endian default produced by NXCDF_map_hdf_type().
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| endianness | NC_ENDIAN_NATIVE, NC_ENDIAN_LITTLE or NC_ENDIAN_BIG. |
| int NXCDF_def_var_fill | ( | int | ncid, |
| int | varid, | ||
| int | no_fill, | ||
| const void * | fill_value ) |
Set fill behavior — the nc_def_var_fill() dispatch entry.
Stores the no-fill flag and a private copy of the fill value on the variable and marks it dcpl_dirty: fill value and fill time are HDF5 creation properties, so _enddef rebuilds the dataset once with them.
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| no_fill | Nonzero to suppress fill values. |
| fill_value | Fill value, or NULL for the type default. |
| int NXCDF_def_var_quantize | ( | int | ncid, |
| int | varid, | ||
| int | quantize_mode, | ||
| int | nsd ) |
Set quantization — the nc_def_var_quantize() dispatch entry.
Quantization records a mode and precision on the variable; it is applied at write time by nxcdf_convert_type(), so no dataset recreation is needed here.
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| quantize_mode | NC_NOQUANTIZE, NC_QUANTIZE_BITGROOM, NC_QUANTIZE_GRANULARBR or NC_QUANTIZE_BITROUND. |
| nsd | Number of significant digits. |
| int NXCDF_del_att | ( | int | ncid, |
| int | varid, | ||
| const char * | name ) |
Delete an attribute from a group or variable.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Attribute name. |
|
static |
Build the scale NAME for a dimension without a variable.
Upstream marks a dimension scale that has no coordinate variable with a NAME attribute of DIM_WITHOUT_VARIABLE plus the dimension length; a scale whose NAME is anything else is read by upstream as a coordinate variable. The HDF5 link keeps the dimension's name.
| dim | Dimension. |
| namebuf | Destination buffer. |
| buflen | Size of namebuf. |
|
static |
Create a standalone dimension-scale dataset for a dimension.
Used when a coordinate-variable relationship ends and the dimension no longer shares its dataset with a variable. The scale carries CLASS, NAME and _Netcdf4Dimid attributes like the scales def_dim creates.
| file | nxCDF file state. |
| grp | Group containing the dimension. |
| dim | Dimension. |
| name | Link and scale name. |
| dsetp | Receives the new dataset identifier. |
|
static |
Mirror a loaded _FillValue attribute into var->fill_value.
_FillValue loads as a normal attribute; when present it is the authoritative fill for nc_inq_var_fill() — the DCPL fill message recovered earlier fills only the gap when no attribute exists.
| var | Variable whose attribute index was just populated. |
| int nxcdf_find_var_for_write | ( | int | ncid, |
| int | varid, | ||
| NC_FILE_INFO_T ** | h5, | ||
| NXCDF_FILE_INFO_T ** | file, | ||
| NC_GRP_INFO_T ** | grp, | ||
| NC_VAR_INFO_T ** | var ) |
Common prologue for the def-var setter dispatch functions.
Resolves the variable and file state and checks define-mode write access, so each setter only validates its own arguments.
| ncid | NetCDF file identifier. |
| varid | Variable identifier. |
| h5 | Destination for the NetCDF-4 file state. |
| file | Destination for the nxCDF file state. |
| grp | Destination for the group. |
| var | Destination for the variable. |
| int nxcdf_flush_pending_atts | ( | NC_GRP_INFO_T * | grp | ) |
Materialize attributes deferred while their datatype or dataset was pending — called at _enddef.
Attributes whose datatype was an uncommitted user type, or that live on a user-typed variable whose dataset did not exist yet, are marked atts_pending on the owning group/variable. Once NXCDF_write_types() and the deferred dataset creations have run, this rewrites the pending objects' attribute lists in index order, preserving definition order on disk.
| grp | Group to walk (recursively). |
| int NXCDF_get_att | ( | int | ncid, |
| int | varid, | ||
| const char * | name, | ||
| void * | value, | ||
| nc_type | memtype ) |
Read an attribute's value — the nc_get_att_* dispatch entry.
Reads from the in-memory record (all attributes were loaded at open), converting through nxcdf_convert_type() when the caller asks for a different type. NC_STRING attributes return strdup'd strings the caller owns.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Attribute name. |
| value | Destination buffer. |
| memtype | Requested in-memory type. |
| int NXCDF_get_var_chunk_cache | ( | int | ncid, |
| int | varid, | ||
| size_t * | sizep, | ||
| size_t * | nelemsp, | ||
| float * | preemptionp ) |
Inquire effective chunk cache properties, allowing NULL outputs. A pending or nonchunked variable reports its stored session request. Live chunked variables report the DAPL actually attached to the dataset handle.
Inquire effective live chunk-cache settings or pending requests.
| ncid | File or group identifier. |
| varid | Variable identifier within the group. |
| sizep | Optional byte-capacity destination. |
| nelemsp | Optional hash-slot destination. |
| preemptionp | Optional preemption destination. |
| int NXCDF_inq_att | ( | int | ncid, |
| int | varid, | ||
| const char * | name, | ||
| nc_type * | xtypep, | ||
| size_t * | lenp ) |
Inquire about an attribute — the nc_inq_att() dispatch entry.
Stock NC4_inq_att resolves att->nc_typeid through nc4_find_type(), which knows only stock atomic typeids and the file's user-defined types — NEP atomic types (float16, bitfield, NC_STD_REF, ...) all fail there. This version returns the stored typeid directly, so nc_inq_att() and the generic nc_get_att() work for NEP types.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Attribute name. |
| xtypep | Destination for the attribute's type, or NULL. |
| lenp | Destination for the attribute's length, or NULL. |
| int NXCDF_inq_attid | ( | int | ncid, |
| int | varid, | ||
| const char * | name, | ||
| int * | attnump ) |
Learn an attribute's index by name — the nc_inq_attid() dispatch entry.
The shared NC4_inq_attid cannot intercept the provenance names, which live outside the attribute index; this entry answers them with upstream's NC_EATTMETA (virtual attributes have no index) and otherwise returns the attribute's position in the index.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Attribute name. |
| attnump | Destination for the attribute index. |
| int NXCDF_inq_dim | ( | int | ncid, |
| int | dimid, | ||
| char * | name, | ||
| size_t * | lenp ) |
Inquire about a dimension — the nc_inq_dim() dispatch entry.
Answers from the in-memory tree; for an unlimited dimension lenp is the current length.
| ncid | NetCDF file identifier. |
| dimid | Dimension id. |
| name | Destination for the dimension name. |
| lenp | Destination for the dimension length. |
| int NXCDF_inq_var | ( | int | ncid, |
| int | varid, | ||
| char * | name, | ||
| nc_type * | xtypep, | ||
| int * | ndimsp, | ||
| int * | dimidsp, | ||
| int * | nattsp ) |
Inquire about a variable's name, type, dimensions, and attributes — the nc_inq_var() dispatch entry.
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| name | Destination for the variable name. |
| xtypep | Destination for the variable type. |
| ndimsp | Destination for the rank. |
| dimidsp | Destination for the dimension ids. |
| nattsp | Destination for the number of attributes. |
| int NXCDF_inq_var_all | ( | int | ncid, |
| int | varid, | ||
| char * | name, | ||
| nc_type * | xtypep, | ||
| int * | ndimsp, | ||
| int * | dimidsp, | ||
| int * | nattsp, | ||
| int * | shufflep, | ||
| int * | deflatep, | ||
| int * | deflate_levelp, | ||
| int * | fletcher32p, | ||
| int * | contiguousp, | ||
| size_t * | chunksizesp, | ||
| int * | no_fillp, | ||
| void * | fill_valuep, | ||
| int * | endiannessp, | ||
| unsigned int * | idp, | ||
| size_t * | nparamsp, | ||
| unsigned int * | params ) |
Inquire about all supported properties of a variable — the nc_inq_var_all() dispatch entry.
The kitchen-sink inquiry used internally by netcdf-c; every output pointer is optional. The idp/nparamsp/params filter outputs are never populated — upstream's shared NC4_inq_var_all doesn't populate them either; filter inquiry goes through nc_inq_var_filter_ids()/nc_inq_var_filter_info().
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| name | Destination for the variable name. |
| xtypep | Destination for the variable type. |
| ndimsp | Destination for the rank. |
| dimidsp | Destination for the dimension ids. |
| nattsp | Destination for the number of attributes. |
| shufflep | Destination for the shuffle flag. |
| deflatep | Destination for the deflate flag. |
| deflate_levelp | Destination for the deflate level. |
| fletcher32p | Destination for the Fletcher32 flag. |
| contiguousp | Destination for the contiguous-storage flag. |
| chunksizesp | Destination for the chunk sizes. |
| no_fillp | Destination for the no-fill flag. |
| fill_valuep | Destination for the fill value. |
| endiannessp | Destination for the endianness. |
| idp | Destination for the filter ids. |
| nparamsp | Destination for the filter parameter count. |
| params | Destination for the filter parameters. |
| int NXCDF_load_metadata | ( | NXCDF_FILE_INFO_T * | file, |
| NC_FILE_INFO_T * | h5 ) |
Load all metadata for an open nxCDF file — the entry point NXCDF_open() calls after checking the marker attributes.
Recursively walks the HDF5 file starting at the root group and rebuilds the complete NC_*_INFO_T tree (groups, dimensions, variables, attributes, committed types) that the dispatch entries then operate on. See nxCDF Architecture.
| file | Open nxCDF state. |
| h5 | Common NetCDF-4 file metadata. |
| int NXCDF_map_hdf_type | ( | nc_type | xtype, |
| hid_t * | typep ) |
Map an atomic nc_type to its on-disk HDF5 datatype.
Every netCDF atomic type is stored as a copy of an HDF5 predefined type — little-endian for numerics so files are architecture-independent. The mapping covers the standard types (NC_BYTE…NC_DOUBLE, NC_CHAR, NC_STRING) plus nxCDF's extended set: NC_FLOAT16, NC_BFLOAT16, the HDF5 2.x small floats (FP8/FP6/FP4), complex, bitfields, and the reference type NC_STD_REF. The caller owns the returned hid_t and must H5Tclose it. The inverse mapping (disk → nc_type) is map_nc_type().
| xtype | NetCDF atomic type. |
| typep | Destination for an HDF5 datatype identifier. |
| int NXCDF_put_att | ( | int | ncid, |
| int | varid, | ||
| const char * | name, | ||
| nc_type | datatype, | ||
| size_t | len, | ||
| const void * | value, | ||
| nc_type | memtype ) |
Create or replace an attribute — the nc_put_att_* dispatch entry.
Converts the value from the caller's memory type to the attribute's storage type through nxcdf_convert_type() (overflow returns NC_ERANGE after the write), replaces any same-named attribute in both the in-memory index and HDF5, and persists immediately — attributes are written to the file in define mode, not deferred to _enddef. Reserved (internal) names are rejected.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Attribute name. |
| datatype | NetCDF atomic type. |
| len | Number of elements. |
| value | Attribute data. |
| memtype | In-memory type for the attribute value. |
|
static |
Restore a variable's quantize setting from its _Quantize* attribute.
Upstream persists quantize as a one-element integer attribute whose name encodes the mode; the attribute loads as a normal user-visible attribute, so this mirrors the value into var->quantize_mode and var->nsd for nc_inq_var_quantize() and write-time quantization.
| var | Variable whose attribute index was just populated. |
|
static |
Reattach every variable on a dimension from one scale dataset to another.
Mirrors upstream's rec_detach_scales(): all variables in grp (recursively) that attach old_dset as the scale for dim are detached and re-attached to new_dset. skip is exempted (the coordinate variable being broken/reformed never self-attaches).
| grp | Group to walk. |
| dim | Dimension whose scale changed. |
| old_dset | Previous scale dataset. |
| new_dset | New scale dataset. |
| skip | Variable to exempt, or NULL. |
|
static |
Reform a coordinate-variable relationship.
Upstream nc4_reform_coord_var() semantics: var's dataset becomes the dimension's scale — it gains CLASS/NAME/_Netcdf4Dimid markers, every other variable on the dimension is reattached to it, and the dimension's previous standalone scale (if any) is unlinked.
| file | nxCDF file state. |
| grp | Group containing the dimension. |
| dim | Dimension regaining a coordinate variable. |
| var | Variable whose dataset becomes the scale. |
| int NXCDF_rename_att | ( | int | ncid, |
| int | varid, | ||
| const char * | name, | ||
| const char * | newname ) |
Rename an attribute — the nc_rename_att() dispatch entry.
HDF5 attributes cannot be renamed in place, so the old attribute is deleted and the value rewritten under the new name via NXCDF_put_att(); the in-memory index is rebuilt by delete-and-re-add for the same reason.
| ncid | NetCDF file identifier. |
| varid | Variable id or NC_GLOBAL. |
| name | Current attribute name. |
| newname | New attribute name. |
| int NXCDF_rename_dim | ( | int | ncid, |
| int | dimid, | ||
| const char * | name ) |
Rename a dimension and update its HDF5 link.
| ncid | NetCDF file identifier. |
| dimid | Dimension id. |
| name | New dimension name. |
| int NXCDF_rename_var | ( | int | ncid, |
| int | varid, | ||
| const char * | name ) |
Rename a variable and update its HDF5 link.
| ncid | NetCDF file identifier. |
| varid | Variable id. |
| name | New variable name. |
|
static |
Reopen every owned alias of a variable with its requested cache. Object identity and metadata stay unchanged. If reopening fails, restore the previous DAPL where possible; a failed recovery leaves invalid, not stale, handles and returns an HDF5 error.
| grp | Variable's containing group. |
| var | Variable whose session request should become effective. |
|
static |
Rewrite every attribute on an HDF5 object in index order.
netcdf-c defers attribute writes to _enddef, so the on-disk creation order always matches the metadata index order. nxCDF writes eagerly: a renamed or replaced attribute would land last in HDF5 creation order and reopen in the wrong position. Deleting the indexed attributes and rewriting them in index order keeps the two consistent. Internal (_Netcdf4*, CLASS, ...) attributes are not in the index and are untouched.
| loc | HDF5 object (dataset or group). |
| list | Attribute index. |
| grp | Group used to resolve user-defined datatypes. |
|
static |
Attribute names that are internal to nxCDF/HDF5.
Enable HDF5 attribute creation-order tracking on an object creation property list.
nxCDF (and the NetCDF-4/HDF5 convention generally) stores bookkeeping as ordinary HDF5 attributes: marker attributes like _NxcdfBackend, dimension-scale attributes like CLASS and NAME, and netcdf-c's own conventions like _Netcdf4Coordinates and _FillValue. They must never appear in nc_inq_att* results, so is_reserved_att() filters them during metadata load and nc_put_att/nc_rename_att reject them as user names.
Upstream netcdf-4 tracks attribute creation order on every group and dataset so nc_inq_attname() returns names in creation order after reopen; nxCDF does the same and iterates with H5_INDEX_CRT_ORDER at load.
| ocpl | Object creation property list. |
| int NXCDF_set_var_chunk_cache | ( | int | ncid, |
| int | varid, | ||
| size_t | size, | ||
| size_t | nelems, | ||
| float | preemption ) |
Apply session-only cache settings without recreating dataset storage. Read-only and data-mode calls are permitted. Pending datasets retain the request until creation; live datasets reopen all owned aliases together.
Set session cache parameters and reopen an existing dataset.
| ncid | File or group identifier. |
| varid | Variable identifier within the group. |
| size | Cache capacity in bytes; zero disables raw chunk caching. |
| nelems | Hash slot count; zero is permitted. |
| preemption | Finite cache preemption weight in [0,1]. |
| const char * NXCDF_type_name | ( | nc_type | xtype | ) |
Return the short name for an atomic nc_type.
These names ("float16", "bfloat16", ...) label the in-memory NC_TYPE_INFO_T records set_var_type() builds for atomic-typed variables.
| xtype | NetCDF atomic type. |
| int NXCDF_type_size | ( | nc_type | xtype, |
| size_t * | sizep ) |
Return the in-memory size, in bytes, of an atomic nc_type.
This is the size of one element in a user buffer: NC_STRING is sizeof(char *), references are their opaque token sizes (8 and 12 bytes), the sub-byte small floats round up to 1 byte.
| xtype | NetCDF atomic type. |
| sizep | Destination for the size in bytes. |
|
static |
Report whether a type is (transitively) variable-sized.
Dynamic types — vlens and compounds containing them — carry pointers inside each element, so values must be deep-copied and reclaimed rather than memcpy'd and free'd.
| grp | Group used to resolve user-defined types. |
| xtype | NetCDF atomic or user-defined type. |
| vsp | Destination for the variable-sized flag. |
|
static |
Build an owned access-property list from a variable's session settings.
| var | Variable holding bytes, slots and preemption in netCDF order. |
| daplp | Destination for the owned HDF5 property list. |
|
static |
Write one in-memory attribute to an HDF5 object.
The attribute name/type/length/data come from att; the HDF5 datatype maps from att->nc_typeid.
| loc | HDF5 object (dataset or group) to write on. |
| att | Attribute to write. |
| grp | Group used to resolve user-defined datatypes. |
|
static |
Persist a variable's quantize setting as the upstream _Quantize* attribute.
Upstream stores the mode in the attribute name and the NSD/NSB as a one-element integer attribute on the variable's dataset (libhdf5/nc4hdf.c write_quantize_att), so this writes the identical object — no-op for NC_NOQUANTIZE.
| dataset | Open HDF5 dataset for the variable. |
| var | Variable holding quantize_mode and nsd. |
|
static |
Read one HDF5 attribute into the in-memory model.
Loader helper: opens the attribute, maps its datatype through map_nc_type(), reads the values with a matching memory type, and registers the result via add_att(). Attributes whose datatype does not map to an atomic nc_type fail — the caller skips them so an unrecognised attribute cannot sink a file open.
| loc | HDF5 location identifier. |
| name | Name. |
| list | Attribute index to add to. |
| container | Object that owns the attribute. |
| grp | Group used to resolve committed user-defined datatypes. |
|
static |
Resolve a variable's dimids from its attached dimension scales.
Fallback for variables lacking the _Netcdf4Coordinates attribute: each dimension must have at least one scale attached, resolved by scale_resolve_visitor().
| grp | Group. |
| dset | Variable dataset. |
| ndims | Number of dimensions. |
| dimids | Destination for the resolved dimension IDs. |
|
static |
H5DSiterate_scales visitor resolving one attached scale to a dimid.
Prefers the scale's _Netcdf4Dimid attribute; falls back to matching the scale's name against the group's dimensions for files written without the attribute. Only the first attached scale per dimension is used.
| did | Dimension scale dataset being visited (unused). |
| dim | Dimension index being visited (unused). |
| dsid | Variable dataset the scale is attached to. |
| op_data | resolve_scale_t search context. |
found).
|
static |
Build the NC_TYPE_INFO_T record for an atomic-typed variable.
netcdf-c expects every variable to point at a type record; atomic types get a small synthetic one whose hdr.id is the nc_type itself. The nc_type_class mapping groups the extended types onto classic classes (small floats → NC_FLOAT, bitfields → NC_INT, references → NC_OPAQUE) so shared NC4_* inquiry helpers keep working.
| var | Variable. |
| xtype | NetCDF atomic type. |
|
static |
Write an array of 32-bit integers as an HDF5 attribute.
Helper for _Netcdf4Coordinates, which records a variable's dimids so open can recover them without walking dimension scales. A zero-length attribute uses an H5S_NULL dataspace.
| loc | HDF5 location identifier. |
| name | Name. |
| values | Array of int values to write. |
| len | Number of values. |
|
static |
Write a one-element 32-bit integer HDF5 attribute.
Helper for the hidden id attributes (_Netcdf4Dimid, _Netcdf4Varid).
| loc | HDF5 location identifier. |
| name | Name. |
| value | Data buffer. |
|
static |
Write a null-terminated scalar string HDF5 attribute.
Helper for the hidden marker attributes (CLASS, NAME) written on dimension scales.
| loc | HDF5 location identifier. |
| name | Name. |
| value | Data buffer. |
|
static |